Reputation: 345
I have an issue with a mix of Laravel and Angular routing while trying to catch my non-Laravel routes and present the Angular view..
I got the below error when I added missing method in my app\http\route.php :
FatalErrorException in Facade.php line 216: Call to undefined method Illuminate\Foundation\Application::missing()
I know this will work fine with laravel 5 or down version but not with laravel 5.2 which I am using currently, so how to code in laravel 5.2 ? Any solution ?
route.php looks like :
<?php // app/routes.php
// HOME PAGE ===================================
// I am not using Laravel Blade
// I will return a PHP file that will hold all of our Angular content
Route::get('/', function() {
View::make('index'); // will return app/views/index.php
});
// API ROUTES ==================================
Route::group(['prefix' => 'api'], function() {
// Angular will handle both of those forms
// this ensures that a user can't access api/create or api/edit when there's nothing there
Route::resource('comments', 'CommentController',
['only' => ['index', 'store', 'destroy']]);
});
// CATCH ALL ROUTE =============================
// all routes that are not home or api will be redirected to the frontend
// this allows angular to route them
App::missing(function($exception) {
return View::make('index');
});
Upvotes: 2
Views: 3283
Reputation: 40909
App::missing() has been removed in Laravel 5. You need to define a catch-all route yourself, just make sure you put it at the end of your routes.php:
Route::any('{catchall}', function() {
//some code
})->where('catchall', '.*');
Upvotes: 5