コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Motion $motion, Request $request)
 {
     if (!Auth::user()->can('create-motions')) {
         abort(401, 'You do not have permission to create a motion');
     }
     $file = new File();
     $file->uploadFile('motion_files', 'file', $request);
     if (!$file->save()) {
         abort(403, $file->errors);
     }
     $motionFile = new MotionFile();
     $motionFile->motion_id = $motion->id;
     $motionFile->file_id = $file->id;
     if (!$motionFile->save()) {
         abort(403, $motionFile->errors);
     }
     return $motionFile;
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(array('image' => Input::file('image')), array('image' => 'image'));
     if ($validator->fails()) {
         abort(403, 'file is not an image');
     }
     $file = new File();
     $file->uploadFile('background_images', 'background_images', $request);
     if (!$file->save()) {
         abort(403, $file->errors);
     }
     $backgroundImage = (new BackgroundImage())->secureFill($request->all());
     $backgroundImage->user_id = Auth::user()->id;
     $backgroundImage->file_id = $file->id;
     if (!$backgroundImage->save()) {
         abort(403, $backgroundImage->errors);
     }
     return $backgroundImage;
 }
コード例 #3
-1
ファイル: UserController.php プロジェクト: vitz3/IserveU
 /**
  * Can't update most of the fields once they have been verified, only email/password/pubilc.
  *
  * @param  User   		$user
  * @return Response
  */
 public function update(User $user, Request $request)
 {
     if ($user->id != Auth::user()->id && !Auth::user()->can('administrate-users')) {
         abort(401, 'You do not have permission to edit this user');
     }
     //If the user has the authentication level, they can change some things
     $user->secureFill($request->except('token'));
     if (!$user->save()) {
         //Validation failed
         abort(400, $user->errors);
     }
     if ($request->file('government_identification')) {
         $file = new File();
         $file->uploadFile('government_identification', 'government_identification', $request);
         if (!$file->save()) {
             abort(403, $file->errors);
         }
         $user->government_identification_id = $file->id;
     }
     if ($request->file('avatar')) {
         $file = new File();
         $file->uploadFile('avatars', 'avatar', $request);
         if (!$file->save()) {
             abort(403, $file->errors);
         }
         $user->government_identification_id = $file->id;
     }
     $user->save();
     return $user;
 }