コード例 #1
0
 /**
  * Store a newly created Author in storage.
  *
  * @param CreateAuthorRequest $request
  *
  * @return Response
  */
 public function store(CreateAuthorRequest $request)
 {
     $input = $request->all();
     $input['objectId'] = str_random(10);
     if ($request->file('authorImg')) {
         $uploadImage = $this->uploadImage($request->file('authorImg'), '/authors_photo/');
         $input['authorImg'] = $uploadImage['resize_url'][0];
     }
     $author = $this->authorRepository->create($input);
     Flash::success('Author saved successfully.');
     return redirect(route('authors.index'));
 }
コード例 #2
0
 /**
  * Store a newly created Author in storage.
  * POST /authors
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (sizeof(Author::$rules) > 0) {
         $validator = $this->validateRequestOrFail($request, Author::$rules);
         if ($validator) {
             return $validator;
         }
     }
     $input = $request->all();
     $input['objectId'] = str_random(10);
     $authors = $this->authorRepository->create($input);
     return $this->sendResponse($authors->toArray(), "Author saved successfully");
 }