/**
  * function for send ajax request to view
  *
  * @return Response
  */
 public function listing_ajax()
 {
     //$query = Building::all();
     $query = Building::select('id', 'title', 'type', 'building_size', 'area_size', 'price', 'status_id', 'created_at')->with('status')->get();
     //var_dump($query);
     return Datatable::collection($query)->addColumn('title', function ($model) {
         return $model->title;
     })->addColumn('type', function ($model) {
         return $model->type;
     })->addColumn('building_size', function ($model) {
         return $model->building_size;
     })->addColumn('area_size', function ($model) {
         return $model->area_size;
     })->addColumn('price', function ($model) {
         return $model->price;
     })->addColumn('status_id', function ($model) {
         return $model->status->name;
     })->addColumn('created_at', function ($model) {
         return $model->created_at->format('d-m-Y');
     })->addColumn('show', function ($model) {
         return '<a href="' . action('AdminBuildingsController@detail', $model->id) . '" class="btn btn-small btn-primary btn-constant"><i class="fa fa-eye fa-fw"></i></a>';
     })->addColumn('edit', function ($model) {
         return '<a href="' . action('AdminBuildingsController@edit', $model->id) . '" class="btn btn-small btn-success btn-constant"><i class="fa fa-edit fa-fw"></i></a>';
     })->addColumn('delete', function ($model) {
         return '<form action="' . action('AdminBuildingsController@delete', $model->id) . '" method="POST"><button  type="submit" class="btn  btn-small btn-danger btn-constant" onclick = "return confirm(\'Are you sure?\')"><i class="fa fa-times fa-fw"></i></button></form>';
     })->searchColumns('type', 'price', 'status_id')->orderColumns('id', 'type', 'created_at', 'building_size', 'status_id')->make();
 }