protected function create($data) { return Project::create(['name' => $data['name'], 'description' => $data['description']]); }
public function addProjects($id) { return view('category.projects')->with(['projects' => Project::all(), 'category' => Category::search($id)]); }
public function storeImage($id, Request $request, ProjectFactory $factory) { $directory = sha1($request->file('file')->getClientOriginalName() . date("Y-n-d-His")) . '/'; $factory->createDirectory($directory); $images = $factory->compileImage($directory, $request->file('file'), new ImageProcessor()); $productInstance = Project::find($id); $imageInstance = new Image(['sizes' => json_encode($images), 'caption' => $productInstance->name]); if (!$productInstance->images()->save($imageInstance)) { throw new \Exception('Something went wrong on connecting your uploaded file to the Project. Please try again'); } else { return redirect(route('project.edit.image', $id))->with('success', 'Successfully uploaded!'); } }