← prev | next →
mazcvei 2022-09-14 22:57:51
mazcvei 2022-09-14 22:48:34
$requests[2]->departament is null
😉
mazcvei 2022-09-14 22:58:42
mazcvei 2022-09-14 22:57:51
😉
the third object has no department relationship
Manalalsubaei 2022-09-14 22:58:57
mazcvei 2022-09-14 22:57:51
😉
what about the database?!
DesolatorMagno 2022-09-14 22:58:57

Not object doesn’t mean null, just that is not a object.
DesolatorMagno 2022-09-14 22:59:09
Show the model relationship.
mazcvei 2022-09-14 22:59:14
Manalalsubaei 2022-09-14 22:58:57
what about the database?!
wrong relationship construction, assignation
DesolatorMagno 2022-09-14 23:00:02
mazcvei 2022-09-14 22:59:14
wrong relationship construction, assignation
Exactly, it could even be a field in database with that name that do conflict with the relationshio.
Manalalsubaei 2022-09-14 23:00:06
DesolatorMagno 2022-09-14 22:59:09
Show the model relationship.

Manalalsubaei 2022-09-14 23:00:19
mazcvei 2022-09-14 23:00:32
Manalalsubaei 2022-09-14 23:00:06
add foregein key and local key
mazcvei 2022-09-14 23:01:24
Manalalsubaei 2022-09-14 23:00:06
model has not $table & $fillable properties
mazcvei 2022-09-14 23:02:07
Manalalsubaei 2022-09-14 23:00:19
https://laravel.com/docs/9.x/eloquent-relationships read doc about relationships
Laravel – The PHP Framework For Web Artisans –
LaravelLaravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
DesolatorMagno 2022-09-14 23:02:22
PurchaseRequest::first()->department()->toSql()
That give you the sql that run, and you can see what name for foraign id it expect.
DesolatorMagno 2022-09-14 23:04:32
You can either change the name to departments_id (almost sure that is what it expect) or just expecify the f key.
Manalalsubaei 2022-09-14 23:07:17
mazcvei 2022-09-14 23:01:24

model has not $table & $fillable properties
$fillable I wrote it
Manalalsubaei 2022-09-14 23:14:47
mazcvei 2022-09-14 23:01:24

model has not $table & $fillable properties

mazcvei 2022-09-14 23:15:04
Manalalsubaei 2022-09-14 23:14:47
add fk & local key
Alexkddd 2022-09-14 23:15:20
We are looking for blockchain developer, He must have knowledge of moralis .
Manalalsubaei 2022-09-14 23:15:42
mazcvei 2022-09-14 23:15:04

add fk & local key
in side $fillable ?
mazcvei 2022-09-14 23:15:46
Manalalsubaei 2022-09-14 23:15:42

in side $fillable ?
no
mazcvei 2022-09-14 23:15:56
mazcvei 2022-09-14 23:02:07

https://laravel.com/docs/9.x/eloquent-relationships read doc about relationships
read
Manalalsubaei 2022-09-14 23:16:55
okey.
but i use this way and work very well
Manalalsubaei 2022-09-14 23:17:16
mazcvei 2022-09-14 23:15:46

no
in side megration
Manalalsubaei 2022-09-14 23:24:12
DesolatorMagno 2022-09-14 23:02:22

PurchaseRequest::first()->department()->toSql()
That give you the sql that run, and you can see what name for foraign id it expect.

DesolatorMagno 2022-09-14 23:24:33
so, you see the problem?
Manalalsubaei 2022-09-14 23:27:42
mazcvei 2022-09-14 23:15:04

add fk & local key

Manalalsubaei 2022-09-14 23:29:08
DesolatorMagno 2022-09-14 23:24:33

so, you see the problem?
I don’t know?
DesolatorMagno 2022-09-14 23:30:14
the Fk have a different name that what Laravel expect, so you need to specify the name, you have deparment_id it expect departments_id
Manalalsubaei 2022-09-14 23:34:54
Manalalsubaei 2022-09-14 23:46:22
DesolatorMagno 2022-09-14 23:30:14

the Fk have a different name that what Laravel expect, so you need to specify the name, you have deparment_id it expect departments_id

Manalalsubaei 2022-09-14 23:46:35
mazcvei 2022-09-14 23:15:04

add fk & local key
I added it.
Manalalsubaei 2022-09-14 23:47:32
but no use
DesolatorMagno 2022-09-14 23:48:58
DesolatorMagno 2022-09-14 23:02:22

PurchaseRequest::first()->department()->toSql()
That give you the sql that run, and you can see what name for foraign id it expect.
Do these again and see if it changed
Manalalsubaei 2022-09-14 23:50:40
DesolatorMagno 2022-09-14 23:52:34
You know that deparment relationship is the one that you are trying to access, right?
← prev | next →