Reputation: 10230
I have the below form in a larvel view:
<div id="admin">
<h1>Products Admin Panel</h1><hr>
<p>Here you can view, delete, and create new products.</p>
<h2>Products</h2><hr>
<!--admin/fileupload/create-->
{{ Form::open(array('url'=>'admin/products/create' , 'files'=>true)) }}
<p>
{{ Form::file('image') }}
</p>
{{ Form::submit('Create Product' , array('class'=>'secondary-cart-btn')) }}
{{ Form::close() }}
</div> <!-- end admin -->
I am new to laravel and basically just want to understand , in the URL when i specify 'url'=>'admin/products/create'
, what is laravel going to look for ?
a modal
called products ? or a controller
called products ? and a method getCreate
or postCreate
inside it ? what is admin
then , i want to understand how laravel interprets this blade form url , can anybody explain ?
I want somebody to explain to me how does laravel interpret blade form url ?
Upvotes: 0
Views: 56
Reputation: 2284
In laravel,you will specify which url to be processed by which controller and by which method inside that controller.This specify must be do in routes.php file that is located in projectname/app/Http/routes.php .
When you specify the 'url'=>'admin/products/create'
you must define the route in routes.php .
Route can be define in different ways like:
Route::get('admin/products/create','ProductController@crete');
Here you can use get
or post
according to your request.
Another way you can do is
Route::get('admin/products/create',array(
'as'=> 'create-product',
'uses'=>'ProductController@create'
));
Now , you can do like this route('create-product');
instead of 'url'=>'admin/products/create'
.
Another way by using Route group
Route::group(['prefix'=>'admin'],function(){
Route::group(['prefix'=>'products'],function(){
Route::get('/create',array(
'as'=>'create-product',
'uses'=> 'ProductController@create'
));
// Here you can define other route that have the url like /admin/products/*
});
});
Now you can do like route('create-product')
or 'url'=>'admin/products/create'
Advantage
For more info check the documentation Here
Upvotes: 1