app/Http/Controllers/BooksController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $this->validate($request,[
            'name' => 'required',
            'author' => 'required'
        ]);
        $book = new Book();
        $book->name = $request->name;
        $book->author = $request->author;
        $book->user_id = Auth::user()->id;
        $book->save();
        return redirect ('books');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required' , 'author' => 'required' ] ) ; $ book = new Book ( ) ; $ book -> name = $ request -> name ; $ book -> author = $ request -> author ; $ book -> user_id = Auth :: user ( ) -> id ; $ book -> save ( ) ; return redirect ( 'books' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .