-2
$check=  \DB::table('teachers')
    ->select('subjects1.sub_code','subjects1.sub_name','standards.std_name','divisions.div_name')
    ->leftjoin('standards','teachers.std_id','=','standards.id')
    ->leftjoin('divisions','teachers.div_id','=','divisions.id')
    ->leftjoin('subjects1','teachers.std_id','=','subjects1.standard_id')
    ->where('teachers.id',$teacher_id)
    ->get();

if (!empty($check) )   {  
    $result['status']  = 'success';
    $temp_mess        .= 'Class Teacher Class Subject Details.';
    $result['message'] = $temp_mess;   

    $arr = array('subjects'=>$check, 'response' => 'success','message' => 'Teacher Class Allocation Details');
    echo json_encode($arr);
    exit;
}
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
  • 1
    Is there an issue or are you simply informing us? Please read: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) and also [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – M. Eriksson Apr 24 '17 at 11:44
  • There are so many questions here. What does the db look like? What does `$teacher_id` contain and where does it come from? Why are you adding data to the `$result` array which isn't even used? Why do you append text to `$temp_mess` when there's no sign of it being defined? Is there even data in the database that would return something? And the most interesting would be _what_ it is that returns null? The query? $check? json_encode()? – M. Eriksson Apr 24 '17 at 11:52
  • Possible duplicate of [Laravel 5.2 Validation Error not appearing in blade](http://stackoverflow.com/questions/36784253/laravel-5-2-validation-error-not-appearing-in-blade) – Helena Hannah George Apr 24 '17 at 12:33

1 Answers1

1

You forgot '=' in the where

->where('teachers.id','=',$teacher_id) 
  • If the condition is a simple `=`, you can omit that from the `where`. From the doc: _"For convenience, if you simply want to verify that a column is equal to a given value, you may pass the value directly as the second argument to the where method"_. https://laravel.com/docs/5.2/queries#where-clauses – M. Eriksson Apr 24 '17 at 11:57