?
Current File : /home/sanghavirealty/public_html/appazwer/Models/Widget.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Widget extends Model
{
    use HasFactory;
    public $table="widgetstbl";

    const CREATED_AT = 'createdate';
    const UPDATED_AT = 'modifydate';


    // protected $casts = [
    //     'visibileType' => 'string',
    // ];


    public function getWidgetAdType(){
    
    return $this->belongsTo(Product::class, 'type' );
}


public function getWidgetBlockType(){
    
    return $this->belongsTo(Blog::class, 'typeid' );
}





public function getWidgetStatus(){
    
    return $this->belongsTo(Product::class, 'status' );
}

// public function getVideoTemplate()
//     {
//             return $this->belongsTo(Salespage::class, 'videotemplateid');
//     }



public static function ShowValue ($id) { 

     return $Widgetdata = Widget::find($id) ;
     

}



public static function ShowData ($type) {


    $Widgetdata = Widget::Where('type', $type)
    ->Where('currentstatus',0)
    ->get();

    return $Widgetdata ;

}


public static function ShowDataSpecific ($id) {


    $Widgetdata = Widget::Where('id', $id)
    ->Where('currentstatus',0)
    ->first();

    return $Widgetdata ;

}


public static function SingleDataSpecific ($type) {

 


    $Widgetdata = Widget::Where('type', $type)
    ->Where('currentstatus',0)
    ->first();

    return $Widgetdata ;

}




public static function ShowDataRandom ($type) {


    $Widgetdata = Widget::Where('type', $type)
    ->Where('currentstatus',0)
    ->inRandomOrder()
    ->take(2)
    ->get();



    return $Widgetdata ;

}





public static function ShowDataSlider ($type) {


    $Widgetdata = Widget::Where('type', $type)
    ->Where('currentstatus',0)
    ->orderBy('key', 'ASC')
    ->get();

    // dd($Widgetdata);

    return $Widgetdata ;

}



public function getTaskStatus()
{
        return $this->belongsTo(Task::class, 'statusid' );
}

public function getTaskPriority()
{
        return $this->belongsTo(Task::class, 'priorityid' );
}

public function getTaskType()
{
        return $this->belongsTo(Task::class, 'typeid' );
}



public function getTaskFollowupStatus()
{
        return $this->belongsTo(Taskfollowup::class, 'statusid' );
}




}