コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validation = $this->validator(Request::all());
     if ($validation->fails()) {
         return redirect()->back()->withInput(Request::all())->withErrors($validation);
     }
     $data = Request::only($this->requiredkeys());
     unset($data[$this->leftMugshotName]);
     unset($data[$this->centerMugshotName]);
     unset($data[$this->rightMugshotName]);
     $prisoner = Prisoner::create($data);
     $prisoner->left_mug_shot = $this->uploadImage(Request::file($this->leftMugshotName), $this->generatePictureName($this->leftMugshotName, $prisoner));
     $prisoner->center_mug_shot = $this->uploadImage(Request::file($this->centerMugshotName), $this->generatePictureName($this->centerMugshotName, $prisoner));
     $prisoner->right_mug_shot = $this->uploadImage(Request::file($this->rightMugshotName), $this->generatePictureName($this->rightMugshotName, $prisoner));
     $prisoner->save();
     return redirect(route('prisoner.show', ['id' => $prisoner->id]))->with('success', 'Added Successfully');
 }