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
Related
I just updated my application into version 5.3 and in many routes I'm getting
trying to get property of non-object
Like for example I have a resource called post and another called Article where each post can have one Articles. And each Article has one writer. When I do
$article->post->writer;
I get trying to get property 'writer' of non-object
Before updating from 5.2 this route as well as other routes worked perfectly. Am i missing something here? should i do something after composer update has been run successfully?
Edit: The article, the post and the writer all exist in the DB. When I try to return $article I get this.
{
"article": []
}
When i switch back to laravel 5.2 I get the proper article
Edit 2: it is routing bidnings problem. I'm using implicit model binding, so when i pass the ID of the article to my route, Laravel fetches the resource. but Now apparently it doesn't do it. I followed the instructions here for the bindings https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0 but Laravel can't still get the article
It was name bindings issue. Laravel 5.3 needs some configuration in kernel.php as well as in the group route https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
The group should have 'middleware' => ['bindings']
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
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
In Laravel 5.4 have included Composer package "erusev/parsedown": "~1.6"
https://github.com/laravel/framework/blob/5.4/composer.json#L22
But how I can use this class in controller?
I have solved this Question to use parsedown in controller laravel 5.4, we only initial parsedown class without use namespace like this:
$parsedown = new \Parsedown();
$md = $parsedown->text('# this H1 tag');
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().