0
votes

Insert Controller === Insert data to Database

public function create() 
{
  return view('books.create');
}
public function store()
{
  $book=Request::all();
  Book::create($book);
  return redirect('books');
}

** My Url

http://localhost/laravel/bookstore/public/books

** Problem show in my browser

Whoops, looks like something went wrong.

1/1 ErrorException in BookController.php line 40:

Non-static method Illuminate\Http\Request::all() should not be called statically, assuming $this from incompatible context

2
what is the question?fico7489

2 Answers

0
votes

Please use this Please check have you used this after namespace

use Illuminate\Http\Request;

After that you can use this.

public function store(Request $request) 
{
  $book=$request->all();
  Book::create($book);
  return redirect('books');
}

I think this will help.

0
votes

change this

use Illuminate\Http\Request;

into

use Request;