/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $arr['name'] = $request->input('name'); $arr['author'] = $request->input('author'); $arr['lang'] = $request->input('lang'); $arr['year'] = $request->input('year'); $arr['user'] = session()->get('VKusr'); $arr['taken'] = 0; $arr['current_owner'] = session()->get('VKusr'); $arr['description'] = $request->input('description'); if (Input::file('photo')) { $img = $arr['user'] . ' ' . $arr['name']; $img = Str::slug($img); $extension = Input::file('photo')->getClientOriginalExtension(); $img = $img . '.' . $extension; Input::file('photo')->move('images/books', $img); $arr['photo'] = 'images/books/' . $img; } $book = Book::create($arr); HistoryController::create(session()->get('VKusr'), 0, $book->id); return redirect('/'); }