/** * @param array $data * @param int|null $id */ protected function saveWork(array $data = [], $id = null) { // Image Handling if (isset($data['image'])) { $data['image'] = $this->buildImage($data['slug'], $data['image']); } // We create the Work if ($id === null) { $data['author_id'] = Auth::id(); $this->works->create($data); } else { $this->works->update($data, $id); } }
/** * Home Page. * * @return \Illuminate\View\View */ public function home() { $works = $this->works->all(); return view('frontend.pages.home', compact('works')); }
/** * Display the specified resource. * * @param string $slug * * @return \Illuminate\View\View */ public function show($slug) { $work = $this->works->findByField('slug', $slug)->first(); $works = $this->works->all(); return view('frontend.pages.works.show', compact('work', 'works')); }