Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $unit = new Unit();
     $unit->name = $request->input('name');
     $unit->save();
     return response()->json(['newId' => $unit->id]);
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $object = new Model();
     $params = $request->only('ru_unit', 'en_unit', 'ua_unit', 'ru_text', 'en_text', 'ua_text');
     $filter = $object->validator($params);
     if ($filter->fails()) {
         $error = $filter->errors()->toArray();
         return view('admin.unit.create', ['input' => $params, 'error' => $error]);
     }
     $object->fill($params);
     $object->save();
     return redirect('admin/unit/' . $object->id);
 }
Пример #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateUnitRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateUnitRequest $request)
 {
     $unit = new Unit();
     $unit->fill($request->all());
     $unit->user_id = Auth::user()->id;
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $patch = 'images/units/';
         $name = $unit->id . '.' . $file->getClientOriginalExtension();
         $image = $patch . $name;
         Image::make($file)->fit(650, 360)->save($image);
         $unit->image = $image;
     }
     $unit->save();
     $message = trans('messages.unit_created_successfully');
     Flash::success($message);
     return redirect()->route('teacher.units.show', $unit);
 }