|
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
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
|
|
|
|
|
|
10
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Prepare the admin interface by setting the associated |
|
14
|
|
|
* model, setting the route, and adding custom columns/fields. |
|
15
|
|
|
* |
|
16
|
|
|
* @return void |
|
17
|
|
|
*/ |
|
18
|
|
|
public function setup() : void |
|
19
|
|
|
{ |
|
20
|
|
|
$this->crud->setModel('App\Models\JobPoster'); |
|
21
|
|
|
$this->crud->setRoute('admin/job-poster'); |
|
22
|
|
|
$this->crud->setEntityNameStrings('Job Poster', 'Job Posters'); |
|
23
|
|
|
|
|
24
|
|
|
if (!$this->request->has('order')) { |
|
25
|
|
|
$this->crud->orderBy('close_date_time', 'desc'); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function setupListOperation() |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
// Add the custom blade buttons found in resources/views/vendor/backpack/crud/buttons/. |
|
32
|
|
|
$this->crud->addButtonFromView('line', 'job_admin_edit', 'job_admin_edit', 'end'); |
|
33
|
|
|
$this->crud->addButtonFromView('line', 'jpb_link', 'jpb_link', 'end'); |
|
34
|
|
|
|
|
35
|
|
|
$this->crud->addColumn([ |
|
36
|
|
|
'name' => 'title', |
|
37
|
|
|
'type' => 'text', |
|
38
|
|
|
'label' => 'Title' |
|
39
|
|
|
]); |
|
40
|
|
|
$this->crud->addColumn([ |
|
41
|
|
|
'name' => 'open_date_time', |
|
42
|
|
|
'type' => 'datetime', |
|
43
|
|
|
'label' => 'Open Date' |
|
44
|
|
|
]); |
|
45
|
|
|
$this->crud->addColumn([ |
|
46
|
|
|
'name' => 'close_date_time', |
|
47
|
|
|
'type' => 'datetime', |
|
48
|
|
|
'label' => 'Close Date' |
|
49
|
|
|
]); |
|
50
|
|
|
$this->crud->addColumn([ |
|
51
|
|
|
'name' => 'status', |
|
52
|
|
|
'label' => 'Status', |
|
53
|
|
|
'type' => 'model_function', |
|
54
|
|
|
'function_name' => 'status' |
|
55
|
|
|
]); |
|
56
|
|
|
$this->crud->addColumn([ |
|
57
|
|
|
'name' => 'published', |
|
58
|
|
|
'label' => 'Published', |
|
59
|
|
|
'type' => 'check', |
|
60
|
|
|
]); |
|
61
|
|
|
$this->crud->addColumn([ |
|
62
|
|
|
'name' => 'manager.user.name', |
|
63
|
|
|
'key' => 'manager_user_name', |
|
64
|
|
|
'type' => 'text', |
|
65
|
|
|
'label' => 'Manager', |
|
66
|
|
|
'orderable' => false |
|
67
|
|
|
]); |
|
68
|
|
|
$this->crud->addColumn([ |
|
69
|
|
|
'name' => 'submitted_applications_count', |
|
70
|
|
|
'label' => 'Applications', |
|
71
|
|
|
'type' => 'closure', |
|
72
|
|
|
'function' => function ($entry) { |
|
73
|
|
|
return $entry->submitted_applications_count() > 0 ? |
|
74
|
|
|
'<a href="' . route('manager.jobs.applications', $entry->id) . '" target="_blank">' . $entry->submitted_applications_count() . ' (View <i class="fa fa-external-link"></i>)</a>' : |
|
75
|
|
|
$entry->submitted_applications_count(); |
|
76
|
|
|
} |
|
77
|
|
|
]); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function setupUpdateOperation() |
|
|
|
|
|
|
81
|
|
|
{ |
|
82
|
|
|
$this->crud->addField([ |
|
83
|
|
|
'name' => 'title', |
|
84
|
|
|
'label' => 'Title', |
|
85
|
|
|
'type' => 'text', |
|
86
|
|
|
'attributes' => [ |
|
87
|
|
|
'readonly' => 'readonly' |
|
88
|
|
|
] |
|
89
|
|
|
]); |
|
90
|
|
|
$this->crud->addField([ |
|
91
|
|
|
'name' => 'open_date_time', |
|
92
|
|
|
'label' => 'Open Date', |
|
93
|
|
|
'type' => 'datetime_picker', |
|
94
|
|
|
'datetime_picker_options' => [ |
|
95
|
|
|
'format' => 'YYYY-MM-DD HH:mm:ss', |
|
96
|
|
|
], |
|
97
|
|
|
]); |
|
98
|
|
|
$this->crud->addField([ |
|
99
|
|
|
'name' => 'close_date_time', |
|
100
|
|
|
'label' => 'Close Date', |
|
101
|
|
|
'type' => 'datetime_picker', |
|
102
|
|
|
'datetime_picker_options' => [ |
|
103
|
|
|
'format' => 'YYYY-MM-DD HH:mm:ss', |
|
104
|
|
|
], |
|
105
|
|
|
]); |
|
106
|
|
|
if ($this->crud->getCurrentEntry() && |
|
107
|
|
|
!$this->crud->getCurrentEntry()->published |
|
108
|
|
|
) { |
|
109
|
|
|
$this->crud->addField([ |
|
110
|
|
|
'name' => 'published', |
|
111
|
|
|
'label' => 'Publish', |
|
112
|
|
|
'type' => 'checkbox' |
|
113
|
|
|
]); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|