Friends, help me the old head on the shelves properly stowed.
I honestly can't understand the better relationship from a normal request
Here is an example, I have 3 tables:
where type_object_id foreign key table type_objects, type_service_id foreign key table type_service
I need to get a collection in which fields condition type_services.translit='hot'
If you make a simple request here
LEFT JOIN type_objects ON type_objects.id = payment_services.type_object_id
LEFT JOIN type_services ON type_services.id = payment_services.type_service_id
The output I get all the data I need in abundance.
That's what I got to do with relationships:
class paymentService extends Model
public static function ads()
class typeService extends Model
public function actualAdsPayments()
Here, I will not receive all data, in particular I don't get type_objects->translit, that's what I get on output
#original: array:9 [▼
"id" => 3
"type_object_id" => 3
"object_id" => 1592148
"type_service_id" => 3
"period" => 7
"price" => "50.00"
"updated_at" => "2019-12-12 14:59:31"
"created_at" => "2019-12-11 22:20:42"
"laravel_through_key" => 3
fields: price, period, updated_at, created_at from table payment_services, in the beginning they did not describe as meaningless.
According to the rules of the ORM I have to do everything h/h relationship, but for the life of me do not understand why? If the usual request is for me much clearer and easier, and b/s relationships I don't get all needed fields.
Even if you take the classics, "one author and many books," why me, if I can do one query with a LEFT JOIN operators
Just don't send to dock, I read it a few times, but did not understand the usefulness of relations ((