SESSION 01
Muhammad Rizwan Arshad
Principal Software Engineer, Nextbridge.
July 27, 2015
# composer
create-project
laravel/laravel
{directory_name}
{version}
Route::get('/', function () {
return 'Hello World';
});
Route::post('foo/bar', function () {
return 'Hello World';
});
Route::put('foo/bar', function () {
//
});
Route::delete('foo/bar', function () {
//
});
Route::match(['get', 'post'], '/', function () {
return 'Hello World';
});
Route::any('foo', function () {
return 'Hello World';
});
$url = url('foo');
Route::get('user/{id}', function ($id) { return 'User '.$id; });
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) { // });
Route::get('user/{name}', function ($name) { // })->where('name', '[A-Za-z]+'); Route::get('user/{id}', function ($id) { // })->where('id', '[0-9]+'); Route::get('user/{id}/{name}', function ($id, $name) { // })->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
Route::get('user/profile', ['as' => 'profile', function () { // }]);
Route::get('user/profile', [ 'as' => 'profile', 'uses' => 'UserController@showProfile' ]);
Route::group(['as' => 'admin::'], function () {
Route::get('dashboard', ['as' => 'dashboard', function () {
// Route named "admin::dashboard"
}]);
});
$url = route('profile'); $redirect = redirect()->route('profile');
Route::get('user/{id}/profile', ['as' => 'profile', function ($id) { // }]); $url = route('profile', ['id' => 1]);
Route::group(['prefix' => 'admin'], function () {
Route::get('users', function () {
// Matches The "/admin/users" URL
});
});
Route::group(['prefix' => 'accounts/{account_id}'], function () {
Route::get('detail', function ($account_id) {
// Matches The accounts/{account_id}/detail URL
});
});
<?php echo csrf_field(); ?>
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
{!! csrf_field() !!}
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
abort(404);