Laravel error ; Controller method not found - laravel

I have in routes.php :
Route::any('project/(:num)', array('as' =>'pr', 'uses'=>'ProjectController#getIndex'));
Route::any('project/(:num)/(:any)', array('as' =>'pr', 'uses'=>'ProjectController#(:2)'));
and I am getting an error : Controller method not found
What is the problem I have getIndex
Thanks

Related

why i see Call to undefined method Error?

im learning laravel so if im not well as you are accept my apologies...
my problem is when i try to define a new method in web.php i got error!some times phpstorm sets problem on 'Route'word so i can run my blade pages but sometimes it sets problem on 'get','post','group' ,...and i cant run my app
ill show you how i defined my routes
use Illuminate\Routing\Route;
Route::get('/', function () {
return view('welcome');
});
Route::group(['prefix' => 'admin'] ,function (){
Route::get('/users','UsersController#index');
});
after all this my point is making a controller so i got this error to fix so i can move on...
Named groups in laravel
Route::group(['prefix'=>'admins','as'=>'admin.'], function(){
Route::get('users', ['as' => 'user', 'uses' = > 'UsersController#index']);
});
Also make sure you have index method in your UsersController.
FYR :- https://laraveldaily.com/laravel-5-1-names-for-route-groups/

Custom function in Controller with resource wont work

I have created my own custom function in my RoomsController
public function join($id){
return $id;
}
Then I want to pass variable to it and it says MethodNotAllowedHttpException
And my Form looks like this
{{Form::open(['action'=> ['RoomsController#join', $room->id], 'method' => 'POST' ])}}
{{Form::submit('Join', ['class' => 'btn btn-danger'])}}
{{Form::close()}}
Also have these routes
Route::get('/','PagesController#index');
Route::get('/about', 'PagesController#about');
Route::get('/services', 'PagesController#services');
Route::get('/register', 'PagesController#register');
Route::get('/logout', 'PagesController#logout');
Route::get('/rooms/join', 'RoomsController#join');
Route::resource('posts','PostsController');
Route::resource('rooms','RoomsController');
Auth::routes();
Route::get('/dashboard', 'DashboardController#index');
I have tried in many different ways i dont know why it is not working. All update edit destroy resource functions are working. Thank's for helping :)
You're submitting a POST request but the route is expecting a GET request. If you change your route to Route::post('/rooms/join', 'RoomsController#join'); it should work
change the method to post and put the route below the resource route
Route::resource('rooms','RoomsController');
Route::post('/rooms/join', 'RoomsController#join');

Call to undefined method Illuminate\Routing\ResourceRegistrar::addResourceEmployee()

I have this route:
Route::get('/', function () {
return view('index');
});
Route::resource('admin', 'EmployeeController');
I have model Employee and EmployeeController( with empty resource methods)
Error : Call to undefined method Illuminate\Routing\ResourceRegistrar::addResourceEmployee()
What is wrong with my code? I have used the same approach in other project and it worked.
Route::resource('admin', 'EmployeeController');
is attempting to bind to a model named Admin.
Route::resource('employees', 'EmployeeController');
should work with the model you have. To make it work with admin, name the resource parameter.
Route::resource('admin', 'EmployeeController', ['parameters' => [
'admin' => 'employee'
]]);
edit
Did you reference something outside the Laravel docs to use AddResourceEmployee(). Seems like a custom solution to me.
https://stackoverflow.com/a/16661564/320487

How to fix Route not defined error in view, with Laravel?

I am getting an errorexception on my view(ErrorException in UrlGenerator.php line 296:). This is my view code:
<?php echo basename($file['name']);?>
For a while it worked, but not don't and I don't know why and how to fix it. I guess I must write something in route.php, but not sure what.....
Route::get('home', ['as' => 'home', function () {
return 'home';
}
]);

How to remove missingMethod route when using Route::controller() in Laravel 4?

When I use Route::controller() it will automatically generate a route like: GET|HEAD|POST|PUT|PATCH|DELETE resource/{_missing}.
this will make conflict if I have route like resource/{id}/somethingElse.
Sample code
<?php
Route::controller('page', 'PageController');
Route::Group(['prefix' => 'page/{id}/comments'], function() {
Route::get('/', 'CommentController#index');
Route::post('/', 'CommentController#create'); // <-- this will not work sometimes I don't know why
});
The line I highlighted throws NotFoundHttpException with Controller method not found. message.
Is there anyway to remove that route containing {_missing} parameter?

Resources