|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/lecturebazaar.com/app/Models/Api/ |
Upload File : |
<?php
namespace App\Models\Api;
use App\Models\FeatureWebinar as Model;
class FeatureWebinar extends Model
{
public function webinar()
{
return $this->belongsTo('App\Models\Api\Webinar', 'webinar_id', 'id');
}
public function scopeHandleFilters($query)
{
$request=request() ;
$offset = $request->get('offset', null);
$limit = $request->get('limit', null);
$category = $request->get('cat', null);
if (!empty($category) and is_numeric($category)) {
// $query->with('webinar') ;//->where('webinar.category_id', $category);
$query->whereHas('webinar', function ($q) use ($category) {
$q->where('category_id', $category);
});
}
if (!empty($offset) && !empty($limit)) {
$query->skip($offset);
}
if (!empty($limit)) {
$query->take($limit);
}
return $query;
}
}