laravel / telescope

An elegant debug assistant for the Laravel framework.
https://laravel.com/docs/telescope
MIT License
4.84k stars 577 forks source link

Telescope Query Watcher causes new model to have id = 0 #1483

Closed altiinberiisha closed 4 months ago

altiinberiisha commented 4 months ago

Telescope Version

4.17.6

Laravel Version

8.83.27

PHP Version

8.2.1

Database Driver & Version

No response

Description

When trying to create a new item on a specific model i'm encountering an issue when i hardcode one of the foreign keys In my case i have 3 tables, organisations, users and schedules. User model has a "hasMany" relationship with the Schedule model.

Steps To Reproduce

In my case this is the code to reproduce the error :

$schedule = user()->schedules()->create([ 
'organisation_id' => 1,
'name' => $this->form['name'], 
]);
dd($schedule)

dd results that $schedule has an id = 0

changing the code to

$schedule = user()->schedules()->create([
 'organisation_id' => Organisation::find(1)->id,
 'name' => $this->form['name'], 
]);

fixes the issue, also setting TELESCOPE_QUERY_WATCHER to false fixes this.

crynobone commented 4 months ago

Only Telescope 5 and Laravel 10 (bugfixes) and 11 is the supported version at the moment.

crynobone commented 4 months ago

Hey there,

Unfortunately we don't support this version of the library anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out.

Thanks!