Tinker is a REPL for the Laravel PHP framework.
Questions tagged [tinker]
136 questions
3
votes
2 answers
PHP Error: Class 'Page' not found in laravel 8 tinker
I'm Inserting some dummy data using the factory model class using this command on tinker:
When i run
composer dump-autoload,
php artisan tinker,
Page::factory(10)->create()
Then this error shows
PHP Error: Class 'Page' not found in…

Billal Hossain
- 65
- 8
3
votes
1 answer
PHP Fatal error: Call to undefined function Laravel tinker
I'm trying to establish a relation between two tables (Roles and Abilities) but when I run the function allowTo() it says is undefined.
I tried to clear the cache and config but didn't do anything.
If anyone could help that'd be great, thanks!
Model…

Becks
- 33
- 5
3
votes
2 answers
How does Laravel find and display the dynamic attributes on Eloquent models when using the tinker CLI?
When we use artisan tinker, and reference an Eloquent model object, the REPL automatically prints the model's attributes, much like how it prints the public properties of any standard object we reference:
>>> (object) ['hello' => 'world']
=> {
…

Chris Whalen
- 53
- 7
3
votes
1 answer
Weird results for Nesbot Carbon diffInHours
I was doing some tinkering for another question here on SO. And have some weird behavior for Carbon's diffInHours. The diff of time ahead is not the same as the diff of time past. Here is my tinker commands and return values:
>>>…

Kurt Friars
- 3,625
- 2
- 16
- 29
3
votes
2 answers
Laravel Tinker Error: Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined method Psy\Configuration::getLoop()
I am trying to run php artisan tinker on my project and get this error:
Symfony\Component\Debug\Exception\FatalThrowableError : Call to undefined method Psy\Configuration::getLoop()
at /var/www/[my_project]/vendor/psy/psysh/src/Psy/Shell.php:80
…

Majid Alaeinia
- 962
- 2
- 11
- 27
3
votes
0 answers
Laravel 5: When Creating Model Factory of Enum Datatype Returns InvalidArgumentException: Data missing
I have a table rates for which I want to restrict the rate values from 1 to 5.
// Migration file for rates table
Schema::create('rates', function (Blueprint $table) {
$table->bigIncrements('id');
…

Lizesh Shakya
- 2,482
- 2
- 18
- 42
3
votes
1 answer
Laravel Tinker immediately exits after first command
Whenever I type php artisan tinker, the shell comes up, but whenever I type in any commands and hit the ENTER key, it immediately exits back to the command prompt. Why?

I need help
- 33
- 2
2
votes
0 answers
Python Tinker Scrollbar Style when inactive
My setting for the style of scrollbar only works when it's active--that means the text is long enought for the scrollbar to scroll,if not,the style will turn back to DEFAULT and i don't know how to change its style.code and images are shown…

Sakura Luna
- 21
- 2
2
votes
2 answers
Laravel Artisan Tinker : write command on multiple lines
How can I write a command on two lines with Laravel Artisan Tinker ?
User::whereEmail('john.doe@home.com')
->get()
PHP Parse error: Syntax error, unexpected T_OBJECT_OPERATOR on line 1

DevonDahon
- 7,460
- 6
- 69
- 114
2
votes
1 answer
Laravel 8 - Unable to seed the DataBase / factory error
Hi I am new to creating factories on Laravel and I am setting up a blog website. I had this going just fine and now it isn't working anymore.
When I use "tinker" to add fake data using (App/Models/Post::factory(30)->create();), below error keep…

Malith2007
- 21
- 1
2
votes
1 answer
Laravel Artrisan Tinker on Elastic Beanstalk env() Variables
I am using Elastic Beanstalk for a project and was trying to execute a script via the console. When I did this, I was getting a strange error and tried to use Artisan Tinker to diagnose the problem.
When using Tinker, I found that it was unable to…

ackerchez
- 1,684
- 7
- 28
- 49
2
votes
1 answer
Laravel One To Many (Inverse) / Belongs To return null
I use Laravel 8. I have 3 table. Course table, UserCourse, and User table. I want to get user courses. I tried it with tinker: Course::find(1)->user_courses -it works fine and give back me user_course.
UserCourse::find(1)->user_course - the problem…

xMrViktorx
- 79
- 2
- 9
2
votes
3 answers
Problem 'SQLSTATE[42S02]: Base table or view not found
I have a problem with php artisan tinker, can't find the reason why he wants a 'businesses' table but not a 'business' table.
Help me fix mistakes, I feel I did a lot of them)
My Problem :
Illuminate\Database\QueryException with message…

Mineral
- 39
- 1
- 1
- 7
2
votes
2 answers
Laravel - SQLSTATE[HY001] Unable to allocate sufficient memory - MsSQL
I'm making a second connection of my project in laravel with a view in an MsSql database, I configured my .env and config correctly, however this is an error of memory overflow:
$ php artisan tinker
Psy Shell v0.10.5 (PHP…

Marcius Leandro
- 775
- 1
- 11
- 34
2
votes
1 answer
Laravel 8 + Tinker: How to create dummy data
In previous Laravel version I use this in tinker:
php artisan tinker
factory(App\Banana::class, 3)->create();
But in Laravel 8, it gives this error:
`PHP Error: Class 'Database/Factories/bananaFactory' not found
How to create dummy data in Laravel…

No One
- 553
- 2
- 9
- 24