Answers for "Call to undefined method :last()"

PHP
0

Call to undefined method :last()

php artisan tinker ...

Well if u try to use \App\<class_name>::first();

It really works, for me i mean. But i tried with last \App\<class_name>::last();
and the same with reverse method and didn't work appearing the error message: 
	Call to undefined method :last()
    
So, the solution is better using:
			\App\Fornecedor::get()->first();
            \App\Fornecedor::get()->last();
            \App\Fornecedor::get()->reverse();
            
Why? Because, using get() the laravel recognizes that you are working with 
collections.
Posted by: Guest on March-08-2022

Code answers related to "Call to undefined method :last()"

Browse Popular Code Answers by Language