How to route to a laravel controllers method
Tag : php , By : user160048
Date : March 29 2020, 07:55 AM
To fix the issue you can do When you use the Route::resource method, you're actually creating many different routes in a single call: GET /admin/products maps to an index method on the controller GET /admin/products/create maps to a create method on the controller POST /admin/products maps to a store method on the controller GET /admin/products/{id} maps to a show method on the controller GET /admin/products/{id}/edit maps to an edit method on the controller PUT/PATCH /admin/products/{id} maps to an update method on the controller DELETE /admin/products/{id} maps to a destroy method on the controller // Here is a single GET route
Route::get('products', 'App\Controllers\Admin\ProductsController@index');
// Here is a single POST route
Route::post('products/parser', 'App\Controllers\Admin\ProductsController@parser');
$ php artisan routes
|
one route 2 controllers - Laravel
Tag : php , By : Tony Siu
Date : March 29 2020, 07:55 AM
should help you out I have a route, based on the term i need to call the appropriate controller. for e.g , Create middleware IsBrand, & check if brand exists? Route::group(['middleware' => 'IsBrand'], function () {
Route::get('{term}', 'BrandController');
});
Route::group(['middleware' => 'IsUser'], function () {
Route::get('{term}', 'UserController');
});
<?php
namespace App\Http\Middleware;
use Closure;
class IsBrand
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (App\Brand::where('brand_name', $term)->count())) {
return $next($request);
}
}
}
|
Need Laravel Route::controller and Route::controllers
Date : March 29 2020, 07:55 AM
wish of those help As we know in Laravel 5.2 Route::controller() and Route::controllers() method was deprecated but it was very handy for reducing the number of routes. I was able to write simple route like this Route::controller('admin/invoice','InvoiceController'). With this simple one route, I can manage all things related to making invoice related work by a controller. , You can use Route::resource() or Route::resources(). Example: Route::resource('books', 'BookController');
class BookController extends Controller {
// to list resources.
public function index();
// to show create form.
public function create();
// to store resource in database.
public function store();
// to show single resource.
public function show();
// to show edit form.
public function edit();
// to edit and then store the modified resource in database.
public function update();
// to delete a resource from database.
public function destroy();
}
|
(Laravel) How to use 2 controllers in 1 route?
Date : March 29 2020, 07:55 AM
|
One route and call two controllers in Laravel
Tag : php , By : Sandeep Arneja
Date : March 29 2020, 07:55 AM
|