i want to change in the dtajax function to loop throw the custom query not into the users table.
public function dtajax()
{
$users = User::all();
$users = DB::table('tc_users')
->join('users_tc_users','users_tc_users.tc_users_id', '=','tc_users.id')
->join('users','users.id', '=','users_tc_users.users_id')
->leftJoin('cars','cars.users_id', '=','users.id')
->groupBy('users.id')
->select(DB::raw("users.id as id , users.name as name , users.email as email , users.Expiration_Date as Expiration_Date , users.phone_number as phone_number ,users.allowedcar as allowedcar ,COUNT(cars.id) as cars_count "))
->get("users.id as id , users.name as name , users.email as email , users.Expiration_Date as Expiration_Date , users.phone_number as phone_number ,users.allowedcar as allowedcar,COUNT(cars.id) as cars_count ");
// print_r($users);
$values = DB::table('users')->select($this->listing_cols)->whereNull('deleted_at');
$out = Datatables::of($values)->make(false);
// print_r($out);
$datax = $out->getData();
print_r($datax);
// $datax->data = Datatables::of($users)->make()->getData();
// $data=$datax->data ;
// for($i = 0 ; $i<count($datax->data); $i++){
// foreach ($users as $user){
// // echo $user->cars_count;
// // print_r($user);
// array_push($datax->data[$i],$user->cars_count);
// }
//}
// print_r($data);
$temp_cols=array_push($this->listing_cols,'ttt');
// print_r($temp_cols);
$fields_popup = ModuleFields::getModuleFields('Users');
$temp_field =array_push($fields_popup,'ttt');
for($i=0; $i < count($data); $i++) {
for ($j=0; $j < count($temp_cols); $j++) {
$col = $temp_cols[$j];
// $this->listing_cols->kk;
// echo $col['no_of_cars'];
if($temp_field[$col] != null && starts_with($temp_field[$col]->popup_vals, "@")) {
$datax->data[$i][$j] = ModuleFields::getFieldValue($temp_field[$col], $users, $datax->data[$i][$j]);
// $data->data[$i][$j] .= 'yssss';
}
if($col == $this->view_col) {
$datax->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/users/'.$datax->data[$i][0]).'">'.$datax->data[$i][$j].'</a>';
}
// else if($col == "author") {
// $data->data[$i][$j];
// }
}
if($this->show_action) {
$output = '';
if(Module::hasAccess("Users", "edit")) {
// print_r($datax->data[$i]);
$output .= '<a href="'.url(config('laraadmin.adminRoute') . '/users/'.$datax->data[$i]->id.'/edit').'" class="btn btn-warning btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-edit"></i></a>';
}
if(Module::hasAccess("Users", "delete")) {
$output .= Form::open(['route' => [config('laraadmin.adminRoute') . '.users.destroy', $datax->data[$i]->id], 'method' => 'delete', 'style'=>'display:inline']);
$output .= ' <button class="btn btn-danger btn-xs" type="submit"><i class="fa fa-times"></i></button>';
$output .= Form::close();
}
$datax->data[$i] = (string)$output;
}
}
$out->setData($datax);
return $out;
}
when i remove get() from the query i get coloums not found error when i try to use get data on $users query like that $datax = $users->getData(); i get that error : Call to a member function getData() on array (that's a laraadmin controller)
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2IEniKq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire