Yab\Quarx\Repositories\WidgetRepository::getWidgetBySLUG PHP Method

getWidgetBySLUG() public static method

Find Widgets by given slug.
public static getWidgetBySLUG ( integer $slug ) : Collection | null | static | Widgets
$slug integer
return Illuminate\Support\Collection | null | static | Widgets
    public static function getWidgetBySLUG($slug)
    {
        return Widget::where('slug', $slug)->first();
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Get a widget.
  *
  * @param string $slug
  *
  * @return widget
  */
 public function widget($slug)
 {
     $widget = WidgetRepository::getWidgetBySLUG($slug);
     if (Gate::allows('quarx', Auth::user())) {
         $widget->content .= '<a href="' . url('quarx/widgets/' . $widget->id . '/edit') . '" style="margin-left: 8px;" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span> Edit</a>';
     }
     return $widget->content;
 }