Passed
Push — main ( 3cfdb8...a45320 )
by PRATIK
10:34
created

PostPriority   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 25
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A mount() 0 4 2
A render() 0 3 1
A priorityChanged() 0 6 1
1
<?php
2
3
namespace Adminetic\Website\Http\Livewire\Admin\Post;
4
5
use Livewire\Component;
0 ignored issues
show
Bug introduced by
The type Livewire\Component was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Adminetic\Website\Models\Admin\Post;
7
8
class PostPriority extends Component
9
{
10
    public $post;
11
12
    public $priority;
13
14
    protected $listeners = ['priority_changed' => 'priorityChanged'];
15
16
    public function mount($post)
17
    {
18
        $this->post = $post;
19
        $this->priority = isset($post) ? $post->priority : 1;
20
    }
21
22
    public function priorityChanged(Post $post)
23
    {
24
        $post->update([
25
            'priority' => $this->priority ?? 1
26
        ]);
27
        $this->post = $post;
28
    }
29
30
    public function render()
31
    {
32
        return view('website::livewire.admin.post.post-priority');
33
    }
34
}
35