multiple column relationship in laravel, how we can do relationship in laravel with multiple column

Laravel relationship with multiple column

Laravel relationship with multiple column

In this tutorial we will learn how we can do relationship in laravel with multiple column. For this tutorial i have below code example. I hope you will understand the code or you can comment me below regarding any issue.

<?php

namespace Modules\Sport\Models;

use Illuminate\Database\Eloquent\Model;
use Modules\Sport\Models\Sport;
use Auth;


class League extends Model
{

	protected $table = 'lms_leagues';
    protected $fillable = ['user_id','is_private','sport_id', 'round_to_start','league_name','type','start_datetime','end_datetime','current_round_id'];

    public function leagueuserteam()
    {
        return $this->hasOne('Modules\Frontend\Models\SavedTeam','league_id','id')->where('user_id',Auth::user()->id)->orWhere('round_id','round_to_start')->with('getTeam');
    }

}
Post Created 43

Leave a Reply

Related Posts

Begin typing your search above and press enter to search. Press ESC to cancel.

Back To Top