Passed
Push — main ( 52a9ba...b89683 )
by PRATIK
04:37 queued 14s
created

QuickCategory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 4 1
A submit() 0 13 3
A mount() 0 4 1
1
<?php
2
3
namespace Adminetic\Website\Http\Livewire\Admin\Category;
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\Category;
7
use Cviebrock\EloquentSluggable\Services\SlugService;
0 ignored issues
show
Bug introduced by
The type Cviebrock\EloquentSluggable\Services\SlugService 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...
8
9
class QuickCategory extends Component
10
{
11
    public $model;
12
    public $category_id;
13
    public $name;
14
    public $categoryid;
15
16
    protected $rules = [
17
        'name' => 'required|max:255',
18
    ];
19
20
    public function mount($model, $category_id = null)
21
    {
22
        $this->model = $model;
23
        $this->category_id = $category_id;
24
    }
25
26
    public function submit()
27
    {
28
        $category = Category::create([
29
            'code' => rand(100000, 999999),
30
            'model' => $this->model,
31
            'name' => $this->name,
32
            'category_id' => $this->categoryid ? ($this->categoryid != '' ? $this->categoryid : null) : null,
33
            'slug' => SlugService::createSlug(Category::class, 'slug', $this->name),
34
        ]);
35
36
        $this->category_id = $category->id;
37
38
        $this->emit('quick_category_created');
39
    }
40
    public function render()
41
    {
42
        $parentcategories = Category::whereNull('category_id')->with('childrenCategories')->get();
43
        return view('website::livewire.admin.category.quick-category', compact('parentcategories'));
44
    }
45
}
46