30 lines
851 B
PHP
30 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* Class WidgetArea
|
|
*/
|
|
class WidgetArea extends Model
|
|
{
|
|
public $timestamps = true;
|
|
protected $fillable = [
|
|
'name',
|
|
'code',
|
|
'description'
|
|
];
|
|
protected $guarded = [];
|
|
|
|
public function getWidgets($uniqueCode)
|
|
{
|
|
return DB::table('widget_areas')
|
|
->select('widget_areas.*', 'widgets.widget_type_handler', 'widgets.name as widget_name', 'widgets.settings')
|
|
->where('code', $uniqueCode)
|
|
->join('widget_in_widget_area', 'widget_in_widget_area.widget_area_id', '=', 'widget_areas.id')
|
|
->join('widgets', 'widget_in_widget_area.widget_id', '=', 'widgets.id')
|
|
->orderBy('widget_in_widget_area.position');
|
|
}
|
|
} |