Laravel 5.6 Method [...] does not exist - laravel

My Route:
My Model:
MyController:
End error:
I don't know this file don't working with Laravel 5.6. My friend is trying it with Laravel 4.2 but is working.
Are there any ideas why this isn't working?

You have to start your classnames with a capital in Laravel 5 and up :)
And there is no method 'getall' in your controller.

Either use all() or get() but not getall() because that is not an eloquent method

Related

BadMethodCallException: Method Illuminate\Routing\Route::get does not exist

I'd start a new laravel project, and want to make a controller called ProductController using Artisan, but it ends up with an error
“BadMethodCallException : Method Illuminate\Routing\Route::get does not exist.“
I'm using laravel 6.0
routes:
Route::get('/products', 'ProductController#index');
Command used:
php artisan make:controller ProductController
Import the Route facade instead of Illuminate\Routing\Route
use Illuminate\Support\Facades\Route;
you maybe
use
href="{{route('--')}}"
instead of
href="{{url('---')}}"
for routing in your blade , just change it to href="{{url('---')}}"

Datattables Laravel 5.4 - FatalThrowableError Call to undefined function App\Http\Controllers\Datatables()

I'm using datatables with laravel 5.4, but when I use the datatables()->query():
in providers: Yajra\Datatables\DatatablesServiceProvider::class,
in aliases: 'Datatables' => Yajra\Datatables\Facades\Datatables::class,
My code:
return Datatables()->query( /**query**/ )
return this error in my console:
FatalThrowableError
App\Http\Controllers\Datatables()
I've tried datatables() and Datatables()
Someone with the same problem?
This error happens because Laravel cannot find your package Datatables.
Laravel in controllers, if you are not mapping your classes correctly will always seek the called classes at this point App\Http\Controllers.
Just put use DataTables; or use \Yajra\Datatables\Datatables; at the start of your controller and it shall be fixed. documentation
When you install any package through composer, composer uses namespace to find the package and route functions and classes to it.
you can read more about the namespaces from php.
and you can check this tutorial for namespaces.
Also, Laravel follows the PSR 4 when it comes to autoloading, you can check it from here

Laravel 5.3 Route::resource without REST

I upgrade Laravel 5.1 to 5.3 and have some problem with routes.
In Laravel 5.1 I have route like:
Route::controllers([
'pages/{page_type}' => 'Admin\AdminPagesController',
]);
And in controller I have methods like:
getIndex($type)
postIndex($type, Request $request)
getAdd($type)
postAdd(Request $request)
getEdit($type, $id)
postEdit(Request $request, $id) and others...
But in 5.3 when I created routes:
Route::resource('pages/{page_type}', 'Admin\AdminPagesController');
I got an error
NotFoundHttpException in RouteCollection.php line 161:
or
Route pattern "/master/pages/{page_type}/{{page_type}}" cannot reference variable name "page_type" more than once.
and it generate me route in RESTful
Can anyone help me?
Thanks.
Since there is not alternative to ::controller you need to create separate route for each action if you don't want to use rest:
Route::get('pages/{page_type}', 'Admin\AdminPagesController#getIndex');
Route::post('pages/{page_type}', 'Admin\AdminPagesController#postIndex');
....
Seems that Route::controllers method has been removed in Laravel 5.2, I can't find it in the documentation since then, and doesn't exist in the Illuminate\Routing\Router.php file in Laravel 5.3
You will have to create each route separately for your case. Or you can simply use the Route::resource method, what do you have against it? You can add extra methods to a resource declaring them before the Route::resource call.

Laravel Error: Call to undefined method class::seeJsonStructure()

do i need to use some namespaces or something?
here's the code:
$response = $this->call('POST', 'admin/apps/list', []);
$this->seeJsonStructure([...]);
seeJsonStructure is not available until Laravel 5.2.
You need to upgrade the Laravel version to 5.2.
Since Laravel 5.4, it has been renamed to assertJsonStructure().

how to access to $_GET in Laravel 5.2

I have a little project on Laravel 5.1
And I updated it to 5.2
And now I get this error from my model:
Class 'Input' not found
And this is the code :
if ( \Input::get('angular') ) { ... }
And where do I find it in the documentation ?
I'm new with Laravel
And I didn't find it
Thanks for the help
You need to use:
\Request::input('angular')
instead of
\Input::get('angular')
Reference: Laravel 5.2 Request documention

Resources