public function __construct(Page $page, Content $content, Def $defs) { $this->page = $page->ofType('default'); // only load standard pages. $this->content = $content; $this->definition = array(); foreach ($defs->all() as $def) { $this->definition[$def->id] = $def->definition; } $this->middleware('admin', ['except' => ['index', 'show']]); }
public function scopeofType($query, $defId) { return Def::whereid($defId)->first()->definition; }