1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
6
|
|
|
use Illuminate\Support\Facades\App; |
7
|
|
|
|
8
|
|
|
class JobPosterStatusCrudController extends CrudController |
9
|
|
|
{ |
10
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
11
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Prepare the admin interface by setting the associated |
15
|
|
|
* model, setting the route, and adding custom columns/fields. |
16
|
|
|
* |
17
|
|
|
* @return void |
18
|
|
|
*/ |
19
|
|
|
public function setup(): void |
20
|
|
|
{ |
21
|
|
|
// Eloquent model to associate with this collection of views and controller actions. |
22
|
|
|
$this->crud->setModel('App\Models\Lookup\JobPosterStatus'); |
23
|
|
|
// Custom backpack route. |
24
|
|
|
$this->crud->setRoute('admin/job-poster-status'); |
25
|
|
|
// Custom strings to display within the backpack UI. |
26
|
|
|
$this->crud->setEntityNameStrings('job status', 'job statuses'); |
27
|
|
|
|
28
|
|
|
$this->crud->operation(['update'], function () { |
29
|
|
|
$this->crud->addField([ |
30
|
|
|
'name' => 'key', |
31
|
|
|
'type' => 'text', |
32
|
|
|
'label' => 'key', |
33
|
|
|
'attributes' => ['disabled' => 'disabled'] |
34
|
|
|
]); |
35
|
|
|
$this->crud->addField([ |
36
|
|
|
'name' => 'name', |
37
|
|
|
'type' => 'text', |
38
|
|
|
'label' => 'Name', |
39
|
|
|
'limit' => 120, |
40
|
|
|
]); |
41
|
|
|
$this->crud->addField([ |
42
|
|
|
'name' => 'description', |
43
|
|
|
'type' => 'textarea', |
44
|
|
|
'label' => 'Description', |
45
|
|
|
]); |
46
|
|
|
}); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setupListOperation() |
50
|
|
|
{ |
51
|
|
|
// Required for order logic. |
52
|
|
|
$locale = 'en'; |
53
|
|
|
if (null !== $this->request->input('locale')) { |
54
|
|
|
$locale = $this->request->input('locale'); |
55
|
|
|
} |
56
|
|
|
App::setLocale($locale); |
57
|
|
|
|
58
|
|
|
$this->crud->addColumn([ |
59
|
|
|
'name' => 'id', |
60
|
|
|
'type' => 'text', |
61
|
|
|
'label' => 'ID', |
62
|
|
|
'orderable' => true, |
63
|
|
|
]); |
64
|
|
|
$this->crud->addColumn([ |
65
|
|
|
'name' => 'key', |
66
|
|
|
'type' => 'text', |
67
|
|
|
'label' => 'Key', |
68
|
|
|
'orderable' => true, |
69
|
|
|
]); |
70
|
|
|
$this->crud->addColumn([ |
71
|
|
|
'name' => 'name', |
72
|
|
|
'type' => 'text', |
73
|
|
|
'label' => 'Name', |
74
|
|
|
'orderable' => true, |
75
|
|
|
'limit' => 70, |
76
|
|
|
'orderLogic' => function ($query, $column, $columnDirection) use ($locale) { |
77
|
|
|
return $query->orderBy('name->' . $locale, $columnDirection)->select('*'); |
78
|
|
|
} |
79
|
|
|
]); |
80
|
|
|
$this->crud->addColumn([ |
81
|
|
|
'name' => 'description', |
82
|
|
|
'type' => 'text', |
83
|
|
|
'label' => 'Description', |
84
|
|
|
'orderable' => false, |
85
|
|
|
'limit' => 120, |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|