Exemplo n.º 1
0
 public function storeSection(SectionRequest $request)
 {
     Section::create($request->all());
     flash()->success('Sekcja <b>' . $request->input('name') . '</b> dla zapytań została dodana!');
     return redirect('/admin');
 }
Exemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(SectionRequest $request, $id)
 {
     $section = Section::findOrFail($id);
     if ($request->hasFile('image')) {
         $image = $request->file('image')->getClientOriginalName();
         $request->file('image')->move('img/section/', $image);
         if (Storage::exists('img/section/' . $section->image)) {
             Storage::delete('img/section/' . $section->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);
     if (isset($image)) {
         $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', 'Рубрика обновлена!');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int            $id
  * @param  SectionRequest $request
  * @return Response
  */
 public function update($id, SectionRequest $request)
 {
     $section = $this->section->find($id);
     if (is_null($section)) {
         return redirect()->route('section.index')->with('error', 'Section not found.');
     }
     if ($section->update($request->all())) {
         return redirect('section')->with('success', 'Section successfully updated!');
     }
     return redirect('section')->with('error', 'Problem updating Section!');
 }