/** * 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 seedAccessories() { ElementType::create(['type' => 'vest', 'plural' => 'vests', 'category' => 'accessories']); ElementType::create(['type' => 'blazer', 'plural' => 'blazers', 'category' => 'accessories']); ElementType::create(['type' => 'ring', 'plural' => 'rings', 'category' => 'accessories']); ElementType::create(['type' => 'necklace', 'plural' => 'necklaces', 'category' => 'accessories']); ElementType::create(['type' => 'bracelet', 'plural' => 'bracelets', 'category' => 'accessories']); ElementType::create(['type' => 'bag', 'plural' => 'bags', 'category' => 'accessories']); ElementType::create(['type' => 'hat', 'plural' => 'hats', 'category' => 'accessories']); ElementType::create(['type' => '(sun)glasses', 'plural' => '(sun)glasses', 'category' => 'accessories']); ElementType::create(['type' => 'watch', 'plural' => 'watches', 'category' => 'accessories']); ElementType::create(['type' => 'shawl', 'plural' => 'shawls', 'category' => 'accessories']); ElementType::create(['type' => 'socks', 'plural' => 'socks', 'category' => 'accessories']); ElementType::create(['type' => 'other accessory', 'plural' => 'other accessories', 'category' => 'accessories']); }
/** * Show the form for editing the specified element. * * @param \FashionDifferent\Element $element * @return \Illuminate\Http\Response */ public function edit(Element $element) { $types = ElementType::lists('plural', 'plural'); return view('elements.edit', compact('element', 'types')); }
public function index() { $elements = Element::all(['name', 'description', 'image', 'type']); $types = ElementType::all(); return view('wardrobe.index', compact('elements', 'types')); }