Completed
Push — master ( f93597...e20ab9 )
by ARCANEDEV
06:06
created

Seoable::seo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelSeo\Traits;
2
3
/**
4
 * Trait     Seoable
5
 *
6
 * @package  Arcanedev\LaravelSeo\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 *
9
 * @property  \Arcanedev\LaravelSeo\Models\Seo  seo
10
 *
11
 * @method  \Illuminate\Database\Eloquent\Relations\MorphOne  morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)
12
 */
13
trait Seoable
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Relationships
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * SEO relationship.
21
     *
22
     * @return \Illuminate\Database\Eloquent\Relations\MorphOne
23
     */
24 36
    public function seo()
25
    {
26 36
        return $this->morphOne(\Arcanedev\LaravelSeo\Models\Seo::class, 'seoable');
27
    }
28
29
    /* ------------------------------------------------------------------------------------------------
30
     |  Main Functions
31
     | ------------------------------------------------------------------------------------------------
32
     */
33
    /**
34
     * Create a seo.
35
     *
36
     * @param  array  $attributes
37
     *
38
     * @return \Arcanedev\LaravelSeo\Models\Seo
39
     */
40 36
    public function createSeo(array $attributes)
41
    {
42 36
        return $this->seo()->create($attributes);
43
    }
44
45
    /**
46
     * Update a seo.
47
     *
48
     * @param  array  $attributes
49
     *
50
     * @return bool
51
     */
52 9
    public function updateSeo(array $attributes)
53
    {
54 9
        return $this->seo->update($attributes);
55
    }
56
57
    /**
58
     * Delete a seo.
59
     *
60
     * @return bool|null
61
     */
62 9
    public function deleteSeo()
63
    {
64 9
        return $this->seo->delete();
65
    }
66
67
    /**
68
     * Check if it has seo.
69
     *
70
     * @return bool
71
     */
72 36
    public function hasSeo()
73
    {
74 36
        return ! is_null($this->seo);
75
    }
76
}
77