php - Laravel Eloquent Query Buliding -
i have 4 tables , giving table structure here
user_work
['id', 'user_id', 'work_id']work_sectors
['id', 'name', 'status']works
['id', 'work_sector_id', 'work_type_id', 'work_duration_id', 'name']users
['id', ...]
and models are
class user extends eloquent implements userinterface, remindableinterface { use usertrait, remindabletrait; protected $table = 'users'; public function work() { return $this->belongstomany('work', 'user_work'); } } class work extends \eloquent { protected $fillable = []; protected $table_name = 'works'; public $timestamps = false; public function user() { return $this->belongstomany('user', 'user_work'); } public function sector() { return $this->belongsto('worksector', 'work_sector_id'); } }
in controller have written code
$user = user::with('language')->with('work')->find($userid);
here need name of work_sector table have written wrong code sector name.
so please me write proper function in eloquent method in laravel 4.2.
Comments
Post a Comment