ShopCategory::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class ShopCategory.
7
 */
8 View Code Duplication
class ShopCategory extends ChocolateyModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * Disable Timestamps.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'chocolatey_shop_items_categories';
23
24
    /**
25
     * Primary Key of the Table.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'category_name';
30
31
    /**
32
     * The Appender(s) of the Model.
33
     *
34
     * @var array
35
     */
36
    protected $appends = ['category'];
37
38
    /**
39
     * Store an Shop Country.
40
     *
41
     * @param string $categoryName
42
     *
43
     * @return ShopCategory
44
     */
45
    public function store(string $categoryName): ShopCategory
46
    {
47
        $this->attributes['category_name'] = $categoryName;
48
        $this->timestamps = false;
49
50
        $this->save();
51
52
        return $this;
53
    }
54
55
    /**
56
     * Get Shop Category Name.
57
     *
58
     * @return string
59
     */
60
    public function getCategoryAttribute(): string
61
    {
62
        return $this->attributes['category_name'];
63
    }
64
}
65