FEATURE #1450: add widget overview
This commit is contained in:
@@ -3,22 +3,28 @@
|
||||
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');
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,25 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class WidgetInWidgetArea extends Model
|
||||
{
|
||||
|
||||
protected $table = 'widget_in_widget_area';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'widget_id',
|
||||
'widget_area_id',
|
||||
'position'
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public static function getWidgetIdsFromArea($widgetAreaId)
|
||||
{
|
||||
$models = WidgetInWidgetArea::where('widget_area_id', $widgetAreaId)
|
||||
->get();
|
||||
|
||||
$ids = [];
|
||||
foreach ($models as $model) {
|
||||
$ids[] = $model->widget_id;
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user