Laravel 5.0.34 database seeding error with tinker - php

I am following this laracast tutorial and as I key in this command in tinker:
factory('App\Flyer')->make();
I get this error:
PHP Fatal error: Call to undefined function factory() in eval()'d cod1
My php version locally installed is 5.4.38
So how do I get rid of this error?
PS: I want to avoid upgrading laravel at this stage as it would require me to update my php as well. So looking for some other workaround.

Model factories were added in Laravel 5.1 so it's obvious it won't work in Laravel 5.0.*
Reference: https://laravel.com/docs/5.2/releases#laravel-5.1

Related

Call to undefined function App\Providers\studly_case() after upgrade to Laravel 6.0.x

As I mentioned in the question, I just upgraded the Laravel version of my project from 5.8.* to 6.0.*.
Now I am getting the below error:
In AppServiceProvider.php line 32:
Call to undefined function App\Providers\studly_case()
Is Laravel supposed to throw error in it's own core file ? I was invoking the following command when I got this error, so I suppose this happens with any artisan command:
php artisan list
I saw in docs, that the new function is Str::studly from Str class file. Is it ok to change in the AppServiceProvider.php ?
Referring to the Laravel 6.x docs, I just discovered that the function for converting the string's current case to studly case is moved to Illuminate\Support\Str class, and named as studly().
So I added that dependency and then replaced the studly_case() to Str::studly() in AppServiceProvider.php, and then was able to run the artisan commands just like before.
I wasn't sure that changing AppServiceProvider.php is standard way or not, but it did worked so I am posting the answer here, that way it'll help anyone else facing the same issue.

Call to undefined method Laravel\Lumen\Routing\Router::prefix()

I have tried to debug this on my own to no avail and all related questions found have not helped.
I have a Lumen application I cloned from my online repo on GitLab that giving me this error:
In Facade.php line 239:
Call to undefined method Laravel\Lumen\Routing\Router::prefix()
Please how do I fix this?
My Lumen web.php route file seems to be working fine as follows:
$router->group(['prefix' => 'agent'], function () use ($router) {
$router->post('register-worker', 'UserController#registerWorkerByAgent');
$router->get('workers', 'UserController#getAgentWorkers');
});
but the PHP artisan command is still giving me an error. (see image)
For those that may come across this in the future.
I solved this by downgrading my php version to 7.2 from 7.4
As it turns out. Php 7.4 now returns null at the call of some illuminate functions. This was taking care of by downgrading to 7.2. I encountered this problem with a Lumen framework so I anticipate others might have similar issues as well.
Thanks for all the assists. Hope this helps someone.

Laravel - Exception thrown at Guzzle function when running seeder

Running php artisan db:seed throws the following error: GuzzleHttp\Exception\InvalidArgumentException : IDN conversion failed (errors: IDNA_ERROR_EMPTY_LABEL) at vendor/guzzlehttp/guzzle/src/functions.php:384
Never seen this error before and it doesn't appear to be an issue with my seeder syntax.
The partial exception trace is:
1 GuzzleHttp\_idn_uri_convert()
/home/vagrant/code/companion-2.0/vendor/guzzlehttp/guzzle/src/Client.php:220
2 GuzzleHttp\Client::buildUri()
/home/vagrant/code/companion-2.0/vendor/guzzlehttp/guzzle/src/Client.php:113
I'm running commands within a vagrant/homestead environment. Could this be a version incompatibility?
This is an issue with guzzle 6.5.0. See more info here: https://github.com/guzzle/guzzle/issues/2448
Solution: downgrade to version 6.4.1.
Please, try to upgrade to the latest stable version (6.5.2 at the moment). We did our best to consider all possible installation details, so you should not have this error anymore.
If the error still occurs, please report it as a bug here: https://github.com/guzzle/guzzle/issues.
Right now, the best solution is update, the lastest version works fine

NeoEloquent Undefined property: Illuminate\Database\Query\Builder::$matches

I'm new to Neo4J and Laravel combined. I was trying out the Vinelab\NeoEloquent library to have a wrapper for Eloquent. Now if i try the default laravel auth code it gives me the following error: Undefined property: Illuminate\Database\Query\Builder::$matches.
I haven't changed anything but i was wondering if someone with experience could help me out? Do i need to change something? Registration works. It created the :User node fine. it also gives an error there: Call to a member function lastInsertId() on null.
Please note i use unedited Laravel authentication using the artisan make:auth function. As of writing this I'm using the latest version of Laravel (5.5) and the Vinelab\neoEloquent ^1.4.4 version.
Thanks in advance!

LdapBundle error with symfony 2 version

I'm using this LdapBundle.
I have already installed it, but I catch an error:
Fatal error: Call to undefined method Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension::addSecurityListenerFactory() in C:\wamp\www\trainingboard\src\IMAG\LdapBundle\IMAGLdapBundle.php on line 41
I know that I have to change my Symfony version to 2.1. I tried to change folder Symfony in vendors, but after that I caught another error. So, I can't so simple change Symfony. Can you give me advice what to do?
P.S. Now I'm using the 2.0.9 version of Symfony
IMAGLdapBundle only works with Symfony 2.0.x
Instead you can try FR3DLdapBundle 1.6.x

Categories