Files
Credit-Zombies/app/Models/VideoSetting.php
2026-06-24 18:29:01 +06:00

66 lines
1.7 KiB
PHP

<?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;
}
}