コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(CategoryRequest $request)
 {
     //@tosdo Attribute Save
     $category = Category::create($request->all());
     if ($request->file('file') != "") {
         $category->image_path = $this->uploadImage($request->file('file'), $for = 'categories');
     }
     //Saving Attributes
     $attributes = $request->get('attribute');
     $this->saveAttribute($attributes, $category->id);
     $category->slug = str_slug($request->get('name'));
     //update File Path and Slug
     $category->save();
     return redirect('/admin/category');
 }
コード例 #2
0
ファイル: CategoryController.php プロジェクト: arielcrm/Jini
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function postEdit(CategoryRequest $request, $id)
 {
     $object = Object::find($id);
     if ($request->parent_id) {
         $object->parent_id = $request->parent_id;
     } else {
         $object->parent_id = null;
     }
     $object->author_id = Auth::user()->id;
     $object->name = preg_replace('[ ]', '-', strtolower($request->name));
     $object->title = $request->title;
     $object->content = $request->content;
     $object->excerpt = $request->excerpt;
     if ($request->hasFile('featuredImage')) {
         $file = $request->file('featuredImage');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $destinationPath = public_path() . '/uploads/';
         $newfileName = sha1($filename . time());
         $picture = $newfileName . '.' . $extension;
         $request->file('featuredImage')->move($destinationPath, $picture);
         if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_featured_image')) {
         }
     }
     if ($request->hasFile('contentImage')) {
         $file = $request->file('contentImage');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $destinationPath = public_path() . '/uploads/';
         $newfileName = sha1($filename . time());
         $picture = $newfileName . '.' . $extension;
         $request->file('contentImage')->move($destinationPath, $picture);
         if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_content_image')) {
         }
     }
     $object->save();
     $object->setValue('_tooltip', $request->toolTip);
     return redirect('admin/categories')->with('message', 'Object saved successfully');
 }
コード例 #3
0
ファイル: CategoryController.php プロジェクト: kravn/TTG-CMS
 /**
  * Update the specified category in storage.
  *
  * @param Category $category
  * @param CategoryRequest $request
  * @return Response
  */
 public function update(Category $category, CategoryRequest $request)
 {
     $category->fill($request->all());
     $category->save() ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
     return redirect(route('admin.category.index'));
 }
コード例 #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function postEdit(CategoryRequest $request, $id)
 {
     $object = Object::find($id);
     if ($request->parent_id) {
         $object->parent_id = $request->parent_id;
     } else {
         $object->parent_id = null;
     }
     $object->author_id = Auth::user()->id;
     $object->name = preg_replace('[ ]', '-', strtolower($request->name));
     $object->title = $request->title;
     $object->content = $request->content;
     $object->excerpt = $request->excerpt;
     if ($request->hasFile('featuredImage')) {
         $file = $request->file('featuredImage');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $destinationPath = public_path() . '/uploads/';
         $newfileName = sha1($filename . time());
         $picture = $newfileName . '.' . $extension;
         $request->file('featuredImage')->move($destinationPath, $picture);
         if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_featured_image')) {
         }
     }
     if ($request->hasFile('contentImage')) {
         $file = $request->file('contentImage');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $destinationPath = public_path() . '/uploads/';
         $newfileName = sha1($filename . time());
         $picture = $newfileName . '.' . $extension;
         $request->file('contentImage')->move($destinationPath, $picture);
         if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_content_image')) {
         }
     }
     if ($request->get('score')) {
         $object->score = $request->get('score');
     }
     $object->url = $request->get('url', '');
     if ($request->get('target')) {
         $object->target = '_blank';
     } else {
         $object->target = '_self';
     }
     $object->save();
     $keywords = $request->get('keywords', false);
     $keywords = trim($keywords);
     if ($keywords) {
         $keywords = explode(',', $keywords);
         $keywords = array_map('trim', $keywords);
         $originalKeywords = $object->keywords;
         foreach ($originalKeywords as $item) {
             if (!in_array($item->content, $keywords)) {
                 $item->delete();
             } else {
                 unset($keywords[array_search($item->content, $keywords)]);
             }
         }
         foreach ($keywords as $item) {
             if (trim($item) == '') {
                 continue;
             }
             $object->keywords()->create(['content' => $item]);
         }
     } else {
         $object->keywords()->delete();
     }
     $object->setValue('_tooltip', $request->toolTip);
     return redirect('admin/categories')->with('message', 'Object saved successfully');
 }
コード例 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id, ModelRequest $request)
 {
     try {
         $model = $this->getModel($id);
         try {
             DB::beginTransaction();
             $category_id = $request->input('category_id', null);
             $model->category_id = $category_id;
             $model->description = Purifier::clean($request->input('description'));
             $model->update($request->input());
             DB::commit();
             Flash::info(trans($this->resource_name . 'saved', ['model' => $this->model_name]));
             return redirect(route($this->show_route, [$model->id]));
         } catch (Exception $e) {
             DB::rollBack();
             throw $e;
         }
     } catch (Exception $e) {
         if ($e instanceof PDOException) {
             Flash::error($e->errorInfo[2]);
         } else {
             Flash::error($e->getMessage());
         }
         return $request->response([]);
     }
 }