Tinker is a REPL for the Laravel PHP framework.
Questions tagged [tinker]
136 questions
0
votes
1 answer
How does laravel know the value of request()->getHttpHost()
If I SSH into a server running a laravel app and run in the tinker command line:
print_r(request()->getHttpHost());
This tells me the domain name of the server. But how does it know? Where is this information stored. What does it query to get this…

WillD
- 5,170
- 6
- 27
- 56
0
votes
1 answer
How to rectify class not found in psy shell in laravel tinker?
I am very new to the laravel tinker part, I have one model based on that model I am trying to update some column value but it's throwing an error please help me to resolve the issue.
User::update(["status"=>"active"])->where ('id',1);
Error I am…

Code cracker
- 316
- 1
- 5
- 20
0
votes
1 answer
Laravel 8 BadMethodCallException
I am learning laravel 8, I keep getting this error
BadMethodCallException
Call to undefined method App\Models\Question::factory()
at…

Adebayo Omolumo
- 80
- 1
- 8
0
votes
0 answers
Laravel can't connect to mysql, but Tinker can
I'm having issues connecting to a docker instance of MySQL through Laravel. I've found that by using Tinker, I can connect successfully to the database. e.g, with Tinker, if I run
DB::select("select * from users;");
I'm able to get results.…

blake
- 83
- 7
0
votes
2 answers
Laravel Has undefined contstant App\User from tinker
I wished create model call the laravel artisan tinker.
so I try execute php tinker .. but App\User command was occurred error.
I don't know. what should I do?
My development enviroment
vagrant
php 8.*
laravel 8.*
enter image description here
enter…

Sanghun Yang
- 59
- 1
- 2
- 10
0
votes
1 answer
Laravel Eager Loading - Unexpected Behavior Difference between Code and Tiner
I am working on building a front-end for managing users / roles / permissions with the Spatie > Permissions package in the backend.
A feature I am seeking to implement is selecting a Permission and having this selection then display all Users having…

scott_p
- 57
- 11
0
votes
4 answers
Newbie on Laravel working with relationship models
I'm working to build up a Laravel API and I'm having dome troubles with the models relationships and not sure if I'm doing this well.
I have the following models on my project:
Brand
Category
Kind
Product
Size
ProductImages
This models represents…

jcobo1
- 1,065
- 1
- 18
- 34
0
votes
1 answer
Laravel - Tinker breakpoint in controller
New to Lavarel.
I am trying to debug a controller's method in Laravel, to do so I'm using Tinker (which is based on Psysh).
I added both of these versions to the breakpoint inside the method signup of my…

Chayemor
- 3,577
- 4
- 31
- 54
0
votes
1 answer
Is there a way to get the result of the last operation into a variable
Sometimes when using the php artisan tinker console I do something like the following:
$int->groupBy('tracking_code')->toArray();
instead of:
$a = $int->groupBy('tracking_code')->toArray();
If the operation is very complex and/or is on lots of…

kaan_a
- 3,503
- 1
- 28
- 52
0
votes
2 answers
Tinker with laravel 8, cannot get the Relatioship
i just created users * stories tables, and model , define relationship as shown below
In User Model
public function stories()
{
return $this->hasMany(\App\Story::class);
}
In Story Model
public function user()
{
return…

Ahmed
- 7
- 3
0
votes
2 answers
Collection working as expected in Tinker, but in Controller I get BadMethod
I running into what I assume is so simple I am just overthinking it. I am running the following commands in my Tinker session and it is working as expected:
$game = Games::find(1);
[!] Aliasing 'Games' to 'App\Models\Games' for this Tinker…

Markwow
- 141
- 9
0
votes
0 answers
Maximum execution time of 60 seconds exceeded (need help reducing run time)
the following returns the error in the title, i know a solution is to extend the maximum execution time, but i'm asking how can i make it less than 60seconds, you might notice i removed all queries from the loop so they don't run more than once, do…

salah1337
- 67
- 1
- 7
0
votes
0 answers
Laravel8x: don't create FK with poll_id with Factory
I have two models Poll and DuplicatePoll
with the respective tables:
Schema::create('polls', function (Blueprint $table) {
$table->id();
$table->text('status');
$table->timestamps();
…

bigeyes
- 119
- 1
- 2
- 11
0
votes
1 answer
Class App\Console\Commands\ExampleCommand does not exist when running php artisan tinker
Whenever I try to run php artisan tinker i get:
ReflectionException : Class App\Console\Commands\ExampleCommand does not exist
While that file does indeed not exist, does it have to in order to run tinker?

Bowis
- 541
- 8
- 31
0
votes
1 answer
Using laravel tinker and Carbon to mass update data
im having trouble mass updating data with tinker and Carbon as it does not iterate through the values
input
>>> $d = Child::get('Birthday') //1st command
[!] Aliasing 'Child' to 'App\Child' for this Tinker session.
=>…

Son
- 3
- 3