1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Http\Livewire\Admin\Career; |
4
|
|
|
|
5
|
|
|
use Adminetic\Website\Models\Admin\Career; |
6
|
|
|
use Carbon\Carbon; |
7
|
|
|
use Illuminate\Database\Eloquent\Builder; |
8
|
|
|
use Illuminate\Support\Facades\Blade; |
9
|
|
|
use Rappasoft\LaravelLivewireTables\DataTableComponent; |
10
|
|
|
use Rappasoft\LaravelLivewireTables\Views\Column; |
11
|
|
|
|
12
|
|
|
class CareerTable extends DataTableComponent |
13
|
|
|
{ |
14
|
|
|
public function builder(): Builder |
15
|
|
|
{ |
16
|
|
|
return Career::query()->orderBy('position'); // Eager load anything; // Select some things |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public array $bulkActions = [ |
20
|
|
|
'bulkDelete' => 'Bulk Delete', |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
public function bulkDelete() |
24
|
|
|
{ |
25
|
|
|
Career::whereIn('id', $this->getSelected())->delete(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function configure(): void |
29
|
|
|
{ |
30
|
|
|
$this->setPrimaryKey('id'); |
31
|
|
|
|
32
|
|
|
$this->setEagerLoadAllRelationsEnabled(); |
33
|
|
|
|
34
|
|
|
$this->setEmptyMessage('No career found'); |
35
|
|
|
|
36
|
|
|
$this->setReorderStatus(true); |
37
|
|
|
|
38
|
|
|
$this->setDefaultReorderSort('position', 'asc'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function reorder($items): void |
42
|
|
|
{ |
43
|
|
|
foreach ($items as $item) { |
44
|
|
|
Career::find((int) $item['value'])->update(['position' => (int) $item['order']]); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function columns(): array |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
Column::make('ID', 'id') |
52
|
|
|
->sortable() |
53
|
|
|
->searchable(), |
54
|
|
|
Column::make('Title', 'title') |
55
|
|
|
->sortable() |
56
|
|
|
->searchable(), |
57
|
|
|
Column::make('Group', 'group') |
58
|
|
|
->label( |
59
|
|
|
fn ($row, Column $column) => $row->group ?? '-' |
|
|
|
|
60
|
|
|
) |
61
|
|
|
->sortable() |
62
|
|
|
->searchable(), |
63
|
|
|
Column::make('Designation', 'designation') |
64
|
|
|
->sortable() |
65
|
|
|
->searchable(), |
66
|
|
|
Column::make('Location', 'location') |
67
|
|
|
->sortable() |
68
|
|
|
->searchable(), |
69
|
|
|
Column::make('Salary', 'salary') |
70
|
|
|
->label( |
71
|
|
|
fn ($row, Column $column) => ! is_null($row->salary) ? (currency().$row->salary) : '-' |
|
|
|
|
72
|
|
|
) |
73
|
|
|
->searchable(), |
74
|
|
|
Column::make('Deadline', 'deadline') |
75
|
|
|
->label( |
76
|
|
|
fn ($row, Column $column) => ! is_null($row->deadline) ? (Carbon::crate($row->deadline))->toFormattedDateString() : '-' |
|
|
|
|
77
|
|
|
) |
78
|
|
|
->sortable() |
79
|
|
|
->searchable(), |
80
|
|
|
Column::make('Excerpt', 'excerpt') |
81
|
|
|
->sortable() |
82
|
|
|
->searchable(), |
83
|
|
|
Column::make('Active', 'active') |
84
|
|
|
->format( |
85
|
|
|
fn ($value, $row, Column $column) => '<span class="badge badge-'.($row->getRawOriginal('active') ? 'success' : 'danger').' ">'.($row->getRawOriginal('active') ? 'Active' : 'Inactive').'</span>' |
|
|
|
|
86
|
|
|
) |
87
|
|
|
->html() |
88
|
|
|
->collapseOnTablet(), |
89
|
|
|
Column::make('Apply Button', 'add_apply_button') |
90
|
|
|
->format( |
91
|
|
|
fn ($value, $row, Column $column) => '<span class="badge badge-'.($row->getRawOriginal('add_apply_button') ? 'success' : 'danger').' ">'.($row->getRawOriginal('add_apply_button') ? 'Active' : 'Inactive').'</span>' |
|
|
|
|
92
|
|
|
) |
93
|
|
|
->html() |
94
|
|
|
->collapseOnTablet(), |
95
|
|
|
Column::make('Action') |
96
|
|
|
->label( |
97
|
|
|
fn ($row, Column $column) => Blade::render('<x-adminetic-action :model="$model" route="career"><x-slot name="buttons"><a href="{{ route("career.applications", ["career" => $model->id]) }}"class="btn btn-info btn-air-info p-2 btn-sm"><i class="fa fa-file"></i> <span class="mx-2 p-2"style="background-color: white;color:black">{{ $model->applications->count() }}</span></a></x-slot></x-adminetic-action>', ['model' => $row]) |
|
|
|
|
98
|
|
|
) |
99
|
|
|
->html() |
100
|
|
|
->collapseOnTablet(), |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|