inital commit
This commit is contained in:
65
app/Models/VideoSetting.php
Normal file
65
app/Models/VideoSetting.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class VideoSetting extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable=['link','section_name','status'];
|
||||
|
||||
public function getVideoById($inputData)
|
||||
{
|
||||
return self::where('id',$inputData['section_id'])->first();
|
||||
}
|
||||
public function getVideoList()
|
||||
{
|
||||
return self::where('status',1)-> pluck('link','id');
|
||||
}
|
||||
public function getAllVideo()
|
||||
{
|
||||
$videos=[];
|
||||
$videos=self::get();
|
||||
return $videos;
|
||||
}
|
||||
public function deleteVideos($inputData)
|
||||
{
|
||||
$video=$this->getVideoById($inputData);
|
||||
if(!empty($video))
|
||||
{
|
||||
return self::where('id', $video->id)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
public function insertVideo($inputData){
|
||||
$result = [];
|
||||
$videoObj =self::whereRaw( 'UPPER(`section_name`) LIKE ?', strtoupper($inputData['section_name']) )->first();
|
||||
if(empty($videoObj)) {
|
||||
$result = self::create($inputData);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function updateVideo($inputData){
|
||||
$result = [];
|
||||
$videoObj = $this->getVideoById($inputData);
|
||||
if(!empty($videoObj)){
|
||||
$videoObj->link = $inputData['link'];
|
||||
$videoObj->status = $inputData['status'];
|
||||
$videoObj->save();
|
||||
$result = $videoObj;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getVideoBySectionId($sectionid)
|
||||
{
|
||||
$response=[];
|
||||
$video=self::where('section_id',$sectionid)->first();
|
||||
|
||||
if(!empty($video)) {
|
||||
$response = ['id' => $video->id, 'link' => $video->link, 'section_id' => $video->section_id, 'status' => $video->status];
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user