public function globalSearch($subject) { $videos = Video::where('title', 'LIKE', '%' . $subject . '%')->get(); $results = array(); foreach ($videos as $video) { $results[$video->title] = URL::to('videos/' . $video->id . '/' . $video->slug); } return $results; }
public function render($parameters = array()) { if (isset($parameters['latest']) and $parameters['latest']) { $video = Video::orderBy('created_at', 'DESC')->first(); } else { $video = Video::orderBy(DB::raw('RAND()'))->first(); } if ($video) { return View::make('videos::widget', compact('video'))->render(); } }