php - Laravel Eloquent Query Buliding -


i have 4 tables , giving table structure here

  1. user_work['id', 'user_id', 'work_id']
  2. work_sectors['id', 'name', 'status']
  3. works['id', 'work_sector_id', 'work_type_id', 'work_duration_id', 'name']
  4. 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

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -