/** * Show the application dashboard to the user. * * @return Response */ public function index() { $images = Gallery::slide(); $news = News::latest(4); $pubs = Publication::latest(); $trainings = Training::latest(); $bio = Biography::orderBy('created_at', 'DESC')->first(); return view('index', compact('images', 'news', 'pubs', 'bio', 'trainings')); }
public function editPhoto($id, Request $request) { $biography = Biography::find($id); if (file_exists(public_path() . $biography->photo_url) && is_file(public_path() . $biography->photo_url)) { unlink(public_path() . $biography->photo_url); } $imgUrl = $request->photo_url; $fname = rand() . time(); $output_filename = public_path() . '/uploads/bio/bio_' . $fname . '.png'; $ifp = fopen($output_filename, "wb"); $data = explode(',', $imgUrl); fwrite($ifp, base64_decode($data[1])); fclose($ifp); $fname = '/uploads/bio/bio_' . $fname . '.png'; $biography->update(['photo_url' => $fname]); }