samedi 23 février 2019

hasMany and belongsTo in laravel

I have a student in the users table, Parent is in the same table, And that Parent is the parent of that student in the users table. The student has a schedule in the schedules table. QUESTION: How I can write hasMany and belongsTo to get the proper relation like in following custom query which works fine $schedules = DB::table('users') ->join('schedules', 'users.id', '=', 'schedules.studentID') ->select('users.', 'schedules.', 'users.fname as fname', 'users.lname as lname') ->where('users.parent_id',$request->id) ->where('schedules.status','1')->where('schedules.status_dead','0')->whereIn('schedules.std_status',[1, 2]) ->get(); As shown in the image below



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire