Conditions | 7 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
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 | ]; |
||
104 |