示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SectionRequest $request)
 {
     $section = new Section();
     if ($request->hasFile('image')) {
         $image = $request->file('image')->getClientOriginalName();
         $request->file('image')->move('img/section/', $image);
     } else {
         $image = 'no-image';
     }
     $count = $section->count();
     if ($request->sort_id > 0) {
         $section->sort_id = $request->sort_id;
     } else {
         $section->sort_id = ++$count;
     }
     $section->service_id = $request->service_id;
     $section->title = $request->title;
     $section->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $section->image = $image;
     $section->title_description = $request->title_description;
     $section->meta_description = $request->meta_description;
     $section->text = $request->text;
     if ($request->status == 'on') {
         $section->status = 1;
     } else {
         $section->status = 0;
     }
     $section->save();
     return redirect('/admin/section')->with('status', 'Рубрика добавлена!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SectionRequest $request)
 {
     $section = new Section();
     $count = $section->count();
     if ($request->sort_id > 0) {
         $section->sort_id = $request->sort_id;
     } else {
         $section->sort_id = ++$count;
     }
     $section->service_id = $request->service_id;
     $section->title = $request->title;
     $section->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $section->lang = $request->lang;
     if ($request->status == 'on') {
         $section->status = 1;
     } else {
         $section->status = 0;
     }
     $section->save();
     return redirect('/admin/section')->with('status', 'Раздел добавлен!');
 }