public function store(CreateProjectRequest $request) { if ($request->hasFile('thumb_img')) { $sol = '../'; $file = $request->file('thumb_img'); $filename = uniqid() . $file->getClientOriginalName(); $file_path = $file->move('img/upload', $filename); $url_path = array(); $url_path['link_file'] = $sol . $file_path; $img_linker = ImageSrc::create($url_path); $publish_home = $request->has('publish_home') ? true : false; $data['public_home'] = $publish_home; $data = $request->all(); $project = Project::create($data); $project->img_link()->save($img_linker); } else { Project::create($request->all()); } return redirect('admin/projects'); }