Exemplo n.º 1
0
 /**
  * @param \Minhbang\ILib\UploadRequest $request
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function store(UploadRequest $request)
 {
     $ebook = new Ebook();
     $ebook->fill($request->only(['title', 'summary']));
     $ebook->fileFill($request);
     $ebook->user_id = user('id');
     $ebook->status = $this->statusManager->valueStatus('uploaded');
     $ebook->slug = VnString::to_slug($ebook->title);
     $ebook->enumNotRestore = true;
     $ebook->save();
     return view('message', ['module' => trans('ilib::common.ilib'), 'type' => 'success', 'content' => trans('ilib::common.messages.upload_success'), 'buttons' => [[route('ilib.index'), trans('ilib::common.back_ilib_home'), ['icon' => 'home', 'size' => 'sm', 'type' => 'success']]]]);
 }
Exemplo n.º 2
0
 /**
  * @param \Minhbang\Ebook\Request $request
  * @param \Minhbang\Ebook\Ebook $ebook
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(EbookRequest $request, Ebook $ebook)
 {
     if ($ebook->canUpdate()) {
         $ebook->fill($request->all() + ['featured' => 0]);
         $ebook->fillFeaturedImage($request);
         $ebook->fileFill($request);
         $ebook->user_id = user('id');
         $ebook->fillStatus($request->get('s'));
         $ebook->enumDirty = true;
         $ebook->save();
         Session::flash('message', ['type' => 'success', 'content' => trans('common.update_object_success', ['name' => trans('ebook::common.ebooks')])]);
     } else {
         Session::flash('message', ['type' => 'danger', 'content' => trans('ilib::common.messages.unable_update')]);
     }
     return redirect(route($this->route_prefix . 'backend.ebook.index'));
 }