1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController; |
6
|
|
|
|
7
|
|
|
class JobPosterCrudController extends CrudController |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Prepare the admin interface by setting the associated |
11
|
|
|
* model, setting the route, and adding custom columns/fields. |
12
|
|
|
* |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public function setup() : void |
16
|
|
|
{ |
17
|
|
|
$this->crud->setModel("App\Models\JobPoster"); |
18
|
|
|
$this->crud->setRoute("admin/job-poster"); |
19
|
|
|
$this->crud->setEntityNameStrings('Job Poster', 'Job Posters'); |
20
|
|
|
|
21
|
|
|
$this->crud->denyAccess('create'); |
22
|
|
|
$this->crud->denyAccess('delete'); |
23
|
|
|
|
24
|
|
|
if (!$this->request->has('order')) { |
25
|
|
|
$this->crud->orderBy('close_date_time', 'desc'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$this->crud->addColumn([ |
|
|
|
|
29
|
|
|
'name' => 'title', |
30
|
|
|
'type' => 'text', |
31
|
|
|
'label' => 'Title' |
32
|
|
|
]); |
|
|
|
|
33
|
|
|
$this->crud->addColumn([ |
|
|
|
|
34
|
|
|
'name' => 'open_date_time', |
35
|
|
|
'type' => 'datetime', |
36
|
|
|
'label' => 'Open Date' |
37
|
|
|
]); |
|
|
|
|
38
|
|
|
$this->crud->addColumn([ |
|
|
|
|
39
|
|
|
'name' => 'close_date_time', |
40
|
|
|
'type' => 'datetime', |
41
|
|
|
'label' => 'Close Date' |
42
|
|
|
]); |
|
|
|
|
43
|
|
|
$this->crud->addColumn([ |
|
|
|
|
44
|
|
|
'name' => "status", |
45
|
|
|
'label' => "Status", |
46
|
|
|
'type' => "model_function", |
47
|
|
|
'function_name' => 'status', |
48
|
|
|
]); |
|
|
|
|
49
|
|
|
$this->crud->addColumn([ |
|
|
|
|
50
|
|
|
'name' => "published", |
51
|
|
|
'label' => "Published", |
52
|
|
|
'type' => "check", |
53
|
|
|
]); |
|
|
|
|
54
|
|
|
$this->crud->addColumn([ |
|
|
|
|
55
|
|
|
'name' => 'manager.user.name', |
56
|
|
|
'type' => 'text', |
57
|
|
|
'label' => 'Manager' |
58
|
|
|
]); |
|
|
|
|
59
|
|
|
$this->crud->addColumn([ |
|
|
|
|
60
|
|
|
'name' => "submitted_applications_count", |
61
|
|
|
'label' => "Applications", |
62
|
|
|
'type' => "model_function", |
63
|
|
|
'function_name' => 'submitted_applications_count', |
64
|
|
|
]); |
|
|
|
|
65
|
|
|
|
66
|
|
|
$this->crud->addField([ |
|
|
|
|
67
|
|
|
'name' => 'title', |
68
|
|
|
'label' => "Title", |
69
|
|
|
'type' => 'text', |
70
|
|
|
'attributes' => [ |
71
|
|
|
'readonly' => 'readonly' |
72
|
|
|
] |
73
|
|
|
]); |
|
|
|
|
74
|
|
|
$this->crud->addField([ |
|
|
|
|
75
|
|
|
'name' => 'close_date_time', |
76
|
|
|
'label' => 'Close Date', |
77
|
|
|
'type' => 'datetime_picker', |
78
|
|
|
'datetime_picker_options' => [ |
79
|
|
|
'format' => 'YYYY-MM-DD HH:mm:ss', |
80
|
|
|
], |
81
|
|
|
]); |
|
|
|
|
82
|
|
|
if ($this->crud->getCurrentEntry() && !$this->crud->getCurrentEntry()->published) { |
83
|
|
|
$this->crud->addField([ |
|
|
|
|
84
|
|
|
'name' => 'published', |
85
|
|
|
'label' => 'Publish', |
86
|
|
|
'type' => 'checkbox' |
87
|
|
|
]); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
|
|
|
|
92
|
|
|
* Action for updating an existing Job Poster in the database. |
93
|
|
|
* |
94
|
|
|
* @return \Illuminate\Http\RedirectResponse |
95
|
|
|
*/ |
96
|
|
|
public function update($request) // phpcs:ignore |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
return parent::updateCrud(); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|