mardi 26 septembre 2017

Laravel Relationships: hasManyThrough, belongsTo, belongsToMany

Heyy, I have a Laravel project here, can u guys help me with this question about relationship?

I have the following database structure:

users
    id
    name
    email
    password

event
    id
    description
    city_id

block_range
    id
    event_id

user_block_ranges
    user_id
    block_range_id

Explanation

users: A normal user authentication table. (has a belongsToMany relationship with user_block_ranges)

event: Stores event info. (has a hasMany relationship with block_range)

block_range: Save blocks of time of event. (has a belongsTo relationship with event)

The real question is: how do I get all the events of the user? Through the user_block_ranges then block_range relationship? Maybe using hasManyThrough?

Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2y6rUUt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire