public function byArea($id) { // if (is_numeric($id)) { $model = AZSubject::where('area_id', '=', $id)->orderBy('name', 'ASC')->get(); } else { $id = str_replace("-", " ", $id); $model = AZArea::whereRaw('LOWER(name) = ?', [$id])->orderBy('name', 'ASC')->first(); $model = AZSubject::where('area_id', '=', $model->id)->orderBy('name', 'ASC')->get(); } //$model = AZSubject::all(); return response()->json($model->toArray()); }
public function byAreaSubject($area_id, $subject_id) { // if (is_numeric($subject_id)) { $model = DB::table('az_database')->join('az_database_subject', 'az_database_subject.database_id', '=', 'az_database.id')->join('az_subject', 'az_subject.id', '=', 'az_database_subject.subject_id')->where('az_subject.id', '=', $subject_id)->orderBy('az_database.name', 'ASC')->select('az_database.name as name', 'az_database.url as url', 'az_database.user as user', 'az_subject.name as subject', 'az_database.description as description')->get(); } else { $area_id = str_replace("-", " ", $area_id); $subject_id = str_replace("-", " ", $subject_id); $a_model = AZArea::whereRaw('LOWER(name) = ?', [$area_id])->first(); $s_model = AZSubject::where('area_id', '=', $a_model->id)->whereRaw('LOWER(name) = ?', [$subject_id])->first(); $model = DB::table('az_database')->join('az_database_subject', 'az_database_subject.database_id', '=', 'az_database.id')->join('az_subject', 'az_subject.id', '=', 'az_database_subject.subject_id')->where('az_subject.id', '=', $s_model->id)->orderBy('az_database.name', 'ASC')->select('az_database.name as name', 'az_database.url as url', 'az_database.user as user', 'az_subject.name as subject', 'az_database.description as description')->get(); } //$model = AZSubject::where('area_id', '=', $id)->get(); //$model = AZSubject::all(); return response()->json($model); }