Ad

Laravel Custom Controller Get 404 Error

- 1 answer

i have simple custom controller in route as :

Route::controller(
    'validationMobiles', 'ValidationMobilesController',
    [
        'getIndex' => 'validationMobiles.index',
    ]
);

unfortunately i get 404 error after run this url :

http://localhost/laravel/public/validationMobiles.index

My Controller:

namespace App\Http\Controllers;
class ValidationMobilesController extends Controller
{
    public function getIndex()
    {
        dd('ss');
    }
}

UPDATED:

full controll, this method work fine in laravel 4, in laravel 5 i added namespace:

Route::controller(
    'validationMobiles', 'ValidationMobilesController',
    [
        'getIndex' => 'validationMobiles.index',
        'postUpdate' => 'validationMobiles.update',
        'postEdit' => 'validationMobiles.edit',
        'getDelete' => 'validationMobiles.delete',
        'getAccept' => 'validationMobiles.accept',
        'getResend' => 'validationMobiles.resend',
    ]
);
Ad

Answer

validationMobiles.index is the name of the route you've given, not the url. If your controller method is getIndex, that method will handle a GET request to the validationMobiles/index url (http://localhost/laravel/public/validationMobiles/index).

Ad
source: stackoverflow.com
Ad