2

Blade view and PostsController

When I use {!! Forms::open(['method'=>'post', 'action'=>'PostsController@store']) !!} It errors out.

But when I use {!! Forms::open(['method'=>'post', 'action'=>'App\Http\Contollers\PostsController@store']) !! It works.

Why cant I just use Controller name instead of namespace name?

Thanks for help.

r0pe-12
  • 57
  • 2
  • 9

3 Answers3

3

You could use instead the route name like that

 Form::open(['route' => 'route.name'])

for example, creating a post should be something like that

Form::open(['route' => 'posts.create'])

for more info check the docs here

Joseph
  • 5,644
  • 3
  • 18
  • 44
0

In RouteServiceProvider.php uncomment protected $namespace = 'App\Http\Controllers'; this line

0

As per [ PSR-0, PSR-4 ] coding standard we have to use namespace in code.

In your case, if you don't write the full path you can simply use:

  1. 'action'=>"{{ route('route_name') }}"
  2. 'action'=>"{{ url('url_name') }}"