1 | <?php |
||||
2 | |||||
3 | namespace Raystech\StarterKit\Models; |
||||
4 | |||||
5 | use Illuminate\Database\Eloquent\Model; |
||||
6 | use Cviebrock\EloquentSluggable\Sluggable; |
||||
7 | |||||
8 | use Raystech\StarterKit\Traits\CustomSlugify; |
||||
9 | use Raystech\StarterKit\Traits\TimeHelperTraits; |
||||
10 | |||||
11 | class Post extends Model |
||||
12 | { |
||||
13 | use CustomSlugify; |
||||
14 | use Sluggable; |
||||
15 | use TimeHelperTraits; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
16 | |||||
17 | protected $fillable = [ |
||||
18 | 'post_author', 'post_content', 'post_title', |
||||
19 | 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_password', |
||||
20 | 'post_name', 'to_ping', 'pinged', |
||||
21 | 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count' |
||||
22 | ]; |
||||
23 | |||||
24 | public function getAuthorName() { |
||||
25 | if($this->author) { |
||||
26 | return $this->author->name; |
||||
27 | } else { |
||||
28 | return 'Unknown'; |
||||
29 | } |
||||
30 | } |
||||
31 | |||||
32 | public function author() { |
||||
33 | return $this->belongsTo('App\User', 'post_author'); |
||||
34 | } |
||||
35 | |||||
36 | public static function boot() |
||||
37 | { |
||||
38 | parent::boot(); |
||||
39 | |||||
40 | self::creating(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
41 | // ... code here |
||||
42 | }); |
||||
43 | |||||
44 | self::created(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
45 | // ... code here |
||||
46 | }); |
||||
47 | |||||
48 | self::updating(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
49 | // ... code here |
||||
50 | }); |
||||
51 | |||||
52 | self::updated(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
53 | // ... code here |
||||
54 | }); |
||||
55 | |||||
56 | self::deleting(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
57 | // ... code here |
||||
58 | }); |
||||
59 | |||||
60 | self::deleted(function($model){ |
||||
0 ignored issues
–
show
The parameter
$model 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
61 | // ... code here |
||||
62 | }); |
||||
63 | } |
||||
64 | |||||
65 | public function sluggable() |
||||
66 | { |
||||
67 | return [ |
||||
68 | 'post_name' => [ |
||||
69 | 'source' => 'post_title', |
||||
70 | 'method' => function ($string, $separator) { |
||||
71 | return $this->slugify_th($string, $separator); |
||||
72 | } |
||||
73 | ] |
||||
74 | ]; |
||||
75 | } |
||||
76 | } |
||||
77 |