public function show(Element $element)
 {
     if ($element->isFavourite()) {
         return 'true';
     } else {
         return 'false';
     }
 }
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $elementId = $this->route('element');
     if (Auth::check()) {
         if (Auth::user() == Element::find($elementId)->user) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 /**
  * Fetches a random element, from a specific category if supplied.
  *
  * @param null $ofCategory
  * @return mixed
  */
 public static function getRandomElement($ofCategory = null)
 {
     $elements = null;
     if (!is_null($ofCategory)) {
         $types = ElementType::whereCategory($ofCategory)->get(['type'])->lists('type');
         $elements = Element::whereIn('type', $types)->get();
     } else {
         $elements = Element::all();
     }
     if ($elements->count() > 0) {
         return $elements->random();
     }
 }
 private function randomId()
 {
     return Element::all(['id'])->random()['id'];
 }
 private function SeedElements()
 {
     Element::create(['name' => 'Amazing element', 'description' => 'This is an amazing element', 'type' => 'jeans', 'user_id' => 2]);
 }
 public function index()
 {
     $elements = Element::all(['name', 'description', 'image', 'type']);
     $types = ElementType::all();
     return view('wardrobe.index', compact('elements', 'types'));
 }