Support the ongoing development of Laravel.io →
Eloquent
Last updated 1 year ago.
0

assuming your talking about is eloquent relationship something like this !

// get all the contractors with skiil levels
Contractor::with('skills.skill','skills.level')->get();
/*
	contractor
		name // john doe
		address // some place 
		skills
			skill_id // 1
			contractor_id // 1
			skill
				title // php
			level
				title // senior
*/

Class Contractor extends Model {
	public function skills()
	{
		return $this->hasMany('ContractorSkillLevel');
	}
}

Class ContractorSkillLevel extends Model {
	public function skill()
	{
		// this is assuming you already have the Skill Module
		return $this->belongsTo('Skill');
	}
	public function level()
	{
		// this is assuming you already have the Level Module
		return $this->belongsTo('Level');
	}
}
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.