getRequest() public method

Get request object.
public getRequest ( ) : Request
return Request
 /**
  * @param Request $request
  * @param Builder $htmlBuilder
  * @return $this This Index function include useless function like removeColumn , I wrote some method for show extra usage of datatable if
  * you want more complex datatable query please check the plugin's demo project. PLEASE READ DOCUMENTATION !!!
  * LINK =====> https://github.com/yajra/laravel-datatables-demo
  *
  * YAJRA DATATABLE PLUGINS ......
  */
 public function index(Datatables $datatables)
 {
     if ($this->currentUser->hasAccess('wts.user.show')) {
         if ($datatables->getRequest()->ajax()) {
             $users = DB::table('users')->select(['id', DB::raw("CONCAT(users.first_name,' ',users.last_name) as full_name"), 'slug', 'phone', 'password', 'email', 'created_at', 'updated_at']);
             return Datatables::of($users)->filterColumn('full_name', 'whereRaw', "CONCAT(users.first_name,' ',users.last_name) like ?", ["\$1"])->addColumn('action', function ($user) {
                 if ($this->currentUser->hasAccess('wts.user.edit')) {
                     $edit = $this->createEditButton('/admin/users/' . $user->slug . '/edit');
                 } else {
                     $edit = '';
                 }
                 if ($this->currentUser->hasAccess('wts.user.delete')) {
                     $delete = $this->createDeleteButton($user->id, 'admin.users.destroy');
                 } else {
                     $delete = '';
                 }
                 if ($this->currentUser->hasAccess('wts.user.show')) {
                     $use = '<a href="' . url("admin/users/") . "/" . $user->slug . '/use"
                             class="btn btn-warning" data-tooltip="true" title="Oturumu Kullan" ><i class="fa fa-user"></i></a>&nbsp;';
                 } else {
                     $use = '';
                 }
                 return $use . ' ' . $edit . ' ' . $delete;
             })->make(true);
         }
         $html = $datatables->getHtmlBuilder()->addColumn(['data' => 'full_name', 'name' => 'full_name', 'title' => 'Ad Soyad'])->addColumn(['data' => 'email', 'name' => 'email', 'title' => 'Email'])->addColumn(['data' => 'phone', 'name' => 'phone', 'title' => 'Telefon'])->addColumn(['data' => 'created_at', 'name' => 'created_at', 'title' => 'Created At'])->addColumn(['data' => 'updated_at', 'name' => 'updated_at', 'title' => 'Updated At'])->addColumn(['data' => 'action', 'name' => 'action', 'title' => 'İşlemler', 'orderable' => false, 'searchable' => false])->parameters(array('order' => [3, 'desc']));
         $data = ['menu' => 'users', 'page_title' => 'Kullanıcılar', 'page_description' => 'Sistem Kullanıcılara Ait Özellikler Bu Sayfada Yer Almaktadır'];
         return view('admin.user-group.user.index', $data)->with(compact('html'));
     } else {
         abort(403, $this->accessForbidden);
     }
 }
Example #2
0
 /**
  * Get decorated data as defined in datatables ajax response.
  *
  * @return array
  */
 protected function getAjaxResponseData()
 {
     $this->datatables->getRequest()->merge(['length' => -1]);
     $response = $this->ajax();
     $data = $response->getData(true);
     return $data['data'];
 }
Example #3
0
 public function index(Datatables $datatables)
 {
     $columns = ['id', 'name', 'created_at'];
     if ($datatables->getRequest()->ajax()) {
         return $datatables->of(Client::select($columns))->make(true);
     }
     $html = $datatables->getHtmlBuilder()->columns($columns);
     return view('backend.admin.clients.index', compact('html'));
 }
Example #4
0
 public function show(Datatables $datatables, $id)
 {
     $store = Store::findOrFail($id);
     $device = Device::findOrFail($id);
     if ($datatables->getRequest()->ajax()) {
         return $datatables->of(Visitor::select(['type', 'device_id', 'created_at'])->where('device_id', $device->id)->orderBy('created_at', 'desc'))->make(true);
     }
     $html = $datatables->getHtmlBuilder()->columns(['type', 'created_at']);
     return view('backend.admin.stores.show', compact('device', 'store', 'html'));
 }
Example #5
0
 /**
  * Get request object.
  *
  * @return \Yajra\Datatables\Request|static 
  * @static 
  */
 public static function getRequest()
 {
     return \Yajra\Datatables\Datatables::getRequest();
 }
 /**
  * Get Datatables Request instance.
  *
  * @return \Yajra\Datatables\Request
  */
 public function request()
 {
     return $this->datatables->getRequest();
 }