Passed
Push — task/add_null_states ( 93767f...291766 )
by
unknown
10:33 queued 11s
created

JobPosterCrudController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
eloc 61
dl 0
loc 102
ccs 0
cts 39
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 3 1
B setup() 0 80 5
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
        // Add the custom blade button found in public/vendor/backpack/crud/buttons/full-edit.blade.php
29
        $this->crud->addButtonFromView('line', 'full_edit', 'full_edit', 'end');
30
31
        $this->crud->addColumn([
32
            'name' => 'title',
33
            'type' => 'text',
34
            'label' => 'Title'
35
        ]);
36
        $this->crud->addColumn([
37
            'name' => 'open_date_time',
38
            'type' => 'datetime',
39
            'label' => 'Open Date'
40
        ]);
41
        $this->crud->addColumn([
42
            'name' => 'close_date_time',
43
            'type' => 'datetime',
44
            'label' => 'Close Date'
45
        ]);
46
        $this->crud->addColumn([
47
            'name' => "status",
48
            'label' => "Status",
49
            'type' => "model_function",
50
            'function_name' => 'status',
51
        ]);
52
        $this->crud->addColumn([
53
            'name' => "published",
54
            'label' => "Published",
55
            'type' => "check",
56
        ]);
57
        $this->crud->addColumn([
58
            'name' => 'manager.user.name',
59
            'type' => 'text',
60
            'label' => 'Manager'
61
        ]);
62
        $this->crud->addColumn([
63
            'name' => 'submitted_applications_count',
64
            'label' => 'Applications',
65
            'type' => 'closure',
66
            'function' =>
67
                function ($entry) {
68
                    return $entry->submitted_applications_count() > 0 ?
69
                        '<a href="' . route('manager.jobs.applications', $entry->id) . '">' . $entry->submitted_applications_count() . ' (View <i class="fa fa-external-link"></i>)</a>' :
70
                        $entry->submitted_applications_count();
71
                }
72
        ]);
73
74
        $this->crud->addField([
75
            'name' => 'title',
76
            'label' => "Title",
77
            'type' => 'text',
78
            'attributes' => [
79
                'readonly' => 'readonly'
80
            ]
81
        ]);
82
        $this->crud->addField([
83
            'name' => 'close_date_time',
84
            'label' => 'Close Date',
85
            'type' => 'datetime_picker',
86
            'datetime_picker_options' => [
87
                'format' => 'YYYY-MM-DD HH:mm:ss',
88
            ],
89
        ]);
90
        if ($this->crud->getCurrentEntry() && !$this->crud->getCurrentEntry()->published) {
91
            $this->crud->addField([
92
                'name' => 'published',
93
                'label' => 'Publish',
94
                'type' => 'checkbox'
95
            ]);
96
        }
97
    }
98
99
    /**
100
     * Action for updating an existing Job Poster in the database.
101
     *
102
     * @param \Illuminate\Http\Request $request Incoming form request.
103
     *
104
     * @return \Illuminate\Http\RedirectResponse
105
     */
106
    public function update($request) // phpcs:ignore
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

106
    public function update(/** @scrutinizer ignore-unused */ $request) // phpcs:ignore

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
107
    {
108
        return parent::updateCrud();
109
    }
110
}
111