|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cortex\Fort\DataTables\Backend; |
|
6
|
|
|
|
|
7
|
|
|
use Cortex\Fort\Models\User; |
|
8
|
|
|
use Cortex\Foundation\DataTables\AbstractDataTable; |
|
9
|
|
|
use Cortex\Fort\Transformers\Backend\UserTransformer; |
|
10
|
|
|
|
|
11
|
|
|
class UsersDataTable extends AbstractDataTable |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $model = User::class; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $transformer = UserTransformer::class; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Display ajax response. |
|
25
|
|
|
* |
|
26
|
|
|
* @return \Illuminate\Http\JsonResponse |
|
27
|
|
|
*/ |
|
28
|
|
|
public function ajax() |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->datatables |
|
31
|
|
|
->eloquent($this->query()) |
|
32
|
|
|
->setTransformer(new $this->transformer) |
|
33
|
|
|
->orderColumn('name', 'first_name $1') |
|
34
|
|
|
->make(true); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get columns. |
|
39
|
|
|
* |
|
40
|
|
|
* @return array |
|
|
|
|
|
|
41
|
|
|
*/ |
|
42
|
|
|
protected function getColumns() |
|
43
|
|
|
{ |
|
44
|
|
|
return [ |
|
45
|
|
|
'username' => ['title' => trans('cortex/fort::common.username'), 'render' => '"<a href=\""+routes.route(\'backend.users.edit\', {user: full.id})+"\">"+data+"</a>"', 'responsivePriority' => 0], |
|
|
|
|
|
|
46
|
|
|
'first_name' => ['title' => trans('cortex/fort::common.first_name')], |
|
47
|
|
|
'last_name' => ['title' => trans('cortex/fort::common.last_name')], |
|
48
|
|
|
'email' => ['title' => trans('cortex/fort::common.email'), 'render' => 'data+(data ? " "+(full.email_verified ? "<i class=\"text-success fa fa-check\" title=\""+full.email_verified_at+"\"></i>" : "<i class=\"text-danger fa fa-close\"></i>") : "")'], |
|
|
|
|
|
|
49
|
|
|
'phone' => ['title' => trans('cortex/fort::common.phone'), 'render' => 'data+(data ? " "+(full.phone_verified ? "<i class=\"text-success fa fa-check\" title=\""+full.phone_verified_at+"\"></i>" : "<i class=\"text-danger fa fa-close\"></i>") : "")'], |
|
|
|
|
|
|
50
|
|
|
'country' => ['title' => trans('cortex/fort::common.country')], |
|
51
|
|
|
'created_at' => ['title' => trans('cortex/fort::common.created_at'), 'width' => '15%', 'render' => "moment(data).format('MMM Do, YYYY')"], |
|
|
|
|
|
|
52
|
|
|
'updated_at' => ['title' => trans('cortex/fort::common.updated_at'), 'width' => '15%', 'render' => "moment(data).format('MMM Do, YYYY')"], |
|
|
|
|
|
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.