1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
6
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class ApplicantCrudController |
10
|
|
|
* @package App\Http\Controllers\Admin |
11
|
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud |
12
|
|
|
*/ |
13
|
|
|
class ApplicantCrudController extends CrudController |
14
|
|
|
{ |
15
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
16
|
|
|
|
17
|
|
|
public function setup() |
18
|
|
|
{ |
19
|
|
|
$this->crud->setModel('App\Models\Applicant'); |
20
|
|
|
$this->crud->setRoute(config('backpack.base.route_prefix') . '/applicant'); |
|
|
|
|
21
|
|
|
$this->crud->setEntityNameStrings('applicant', 'applicants'); |
22
|
|
|
$this->crud->denyAccess(['update', 'create', 'delete']); |
23
|
|
|
$this->crud->orderBy('id', 'asc'); |
24
|
|
|
$this->crud->addButtonFromView('line', 'view_applicant', 'view_applicant', 'end'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
protected function setupListOperation() |
28
|
|
|
{ |
29
|
|
|
$this->crud->addColumn([ |
30
|
|
|
'name' => 'id', |
31
|
|
|
'type' => 'number', |
32
|
|
|
'label' => 'ID', |
33
|
|
|
'orderable' => true, |
34
|
|
|
]); |
35
|
|
|
|
36
|
|
|
$this->crud->addColumn([ |
37
|
|
|
'name' => 'user.full_name', |
38
|
|
|
'type' => 'text', |
39
|
|
|
'label' => 'Full Name', |
40
|
|
|
'searchLogic' => function ($query, $column, $searchTerm) { |
41
|
|
|
$query->orWhereHas('user', function ($q) use ($searchTerm) { |
42
|
|
|
$q->where('first_name', 'ilike', '%'.$searchTerm.'%') |
43
|
|
|
->orWhere('last_name', 'ilike', '%'.$searchTerm.'%'); |
44
|
|
|
}); |
45
|
|
|
} |
46
|
|
|
]); |
47
|
|
|
|
48
|
|
|
$this->crud->addColumn([ |
49
|
|
|
'name' => 'user.email', |
50
|
|
|
'type' => 'text', |
51
|
|
|
'label' => 'Email', |
52
|
|
|
'searchLogic' => function ($query, $column, $searchTerm) { |
53
|
|
|
$query->orWhereHas('user', function ($q) use ($searchTerm) { |
54
|
|
|
$q->where('email', 'ilike', '%'.$searchTerm.'%'); |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
]); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|