Octobercms/Laravel Get Id Based On Relation

- 1 answer

In Octobercms I have a list of Shows (Primary). They have a hasMany relation to Seasons and Seasons belong to the show. Then i have episodes that belong to the season (season hasMany episodes)

In the picture below what I want to do is get the season that belongs to the show, not every season created which is what is showing below. Does anyone with laravel or octobercms knowledge know how i could implement this?

The way octobercms works is that it populates the dropdown by relations or manually via the model. Im doing it by relations:

    public $hasMany = [
        'episodes' => ['Teranode\Anime\Models\AnimeEpisode', 'key' => 'season_id'],

These two links would help but not what im trying to get:



I used Request::segement() to get the Id of the show, in the Episode model under the dropdown function:

public function getSeasonOptions()
    return Season::where('anime_id', Request::segment(6))->lists('title', 'id');

This process can help on nested relations, however the segment amount will have to be modified if you make the url of the primary page deeper.

@haakym the $show = Show::find(1); didnt really help since im trying to get the id automatically not manually. I understand that its suppose to be helpful but that example didnt help