how to pluck other table field in laravel ajax and jquery?

i have tables school , class and school_monitoring , it work perfectly now i want live search on school_monitoring using ajax and jquery it not pluck the school_name below is the code

public function actionm(Request $request)
{
 if($request->ajax())
 {
  $output = '';
  $query = $request->get('query');
  if($query != '')
  {
   $data = DB::table('class_monitorings')
     ->where('teacher_name', 'like', '%'.$query.'%')
     ->orWhere('vdate', 'like', '%'.$query.'%')
     ->orWhere('vtime', 'like', '%'.$query.'%')
     ->orWhere('support', 'like', '%'.$query.'%')
     ->orWhere('class_id', 'like', '%'.$query.'%')
     ->orWhere('school_id', 'like', '%'.$query.'%')
   
     ->get();
     
  }
  else
  {
   $data = DB::table('class_monitorings')
  
     ->orderBy('id', 'desc')
     ->get();
  }
  $total_row = $data->count();

 if($total_row > 0)
  {
   foreach($data as $row)
   {
   
    $output .= '
    <tr>
     <td style="border: 1px solid black;">'.$row->school_id .'</td> //it fetch the id from same tbl
        

//i use the following but it not working error 500 show in jquery
             .implode(',',$row->schoolmonit()->get()->pluck(school_name)->toArray()) //Note Not working
             .$row->schoolmonit->school_name. //Not working

       <td style="border: 1px solid black;">'.$row->class_id.'</td>
     <td style="border: 1px solid black;">'.$row->teacher_name.'</td>
     <td style="border: 1px solid black;">'.$row->vdate.'</td>
     <td style="border: 1px solid black;">'.$row->support.'</td>
     <td style="border: 1px solid black;">'.$row->fillby.'</td>
     <td style="border: 1px solid black;"><a class="btn btn-danger" href="'.url('classm/'.$row->id).'/edit">Edit</a>
     <a  class="btn btn-success" href="'.url('classm/'.$row->id).'">Show</a>
        </td>
     
    </tr>';
   }
  }
  else
  {
   $output = '
   <tr>
    <td align="center" colspan="5">No Data Found</td>
   </tr>';
  }
  $data = array(
   'table_data'  => $output,
   'total_data'  => $total_row
  );

  echo json_encode($data);
 }

my questions are

  1. how to pluck the student_name from StudentTable
  2. how to search using student_name in search view

I have created the live search using this tout https://www.webslesson.info/2018/04/live-search-in-laravel-using-ajax.html