sebastiankennedy /
laravel-like
| 1 | <?php |
||||
| 2 | |||||
| 3 | /* |
||||
| 4 | * This file is part of the sebastian-kennedy/laravel-like. |
||||
| 5 | * |
||||
| 6 | * (c) SebastianKennedy <[email protected]> |
||||
| 7 | * |
||||
| 8 | * This source file is subject to the MIT license that is bundled. |
||||
| 9 | */ |
||||
| 10 | |||||
| 11 | namespace SebastianKennedy\LaravelLike; |
||||
| 12 | |||||
| 13 | use Illuminate\Database\Eloquent\Model; |
||||
| 14 | use SebastianKennedy\LaravelLike\Events\LikedEvent; |
||||
| 15 | use SebastianKennedy\LaravelLike\Events\UnLikedEvent; |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * Class Like |
||||
| 19 | * |
||||
| 20 | * @package SebastianKennedy\LaravelLike |
||||
| 21 | */ |
||||
| 22 | class Like extends Model |
||||
| 23 | { |
||||
| 24 | protected $dispatchesEvents = [ |
||||
| 25 | 'created' => LikedEvent::class, |
||||
| 26 | 'deleted' => UnLikedEvent::class, |
||||
| 27 | ]; |
||||
| 28 | |||||
| 29 | 36 | public function __construct(array $attributes = []) |
|||
| 30 | { |
||||
| 31 | 36 | $this->table = config('like.like_table'); |
|||
| 32 | |||||
| 33 | 36 | parent::__construct($attributes); |
|||
| 34 | 36 | } |
|||
| 35 | |||||
| 36 | 9 | public function likable() |
|||
| 37 | { |
||||
| 38 | 9 | return $this->morphTo(); |
|||
| 39 | } |
||||
| 40 | |||||
| 41 | 3 | public function liker() |
|||
| 42 | { |
||||
| 43 | 3 | return $this->relationLoaded('user') ? $this->user : $this->user(); |
|||
|
0 ignored issues
–
show
|
|||||
| 44 | } |
||||
| 45 | |||||
| 46 | 12 | public function user() |
|||
| 47 | { |
||||
| 48 | 12 | return $this->belongsTo(config('auth.providers.users.model'), config('like.foreign_key')); |
|||
| 49 | } |
||||
| 50 | |||||
| 51 | 6 | public function scopeWithType($query, $type) |
|||
| 52 | { |
||||
| 53 | 6 | return $query->where(config('like.morph_many_type'), app($type)->getMorphClass()); |
|||
|
0 ignored issues
–
show
The method
getMorphClass() does not exist on Illuminate\Contracts\Foundation\Application.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 54 | } |
||||
| 55 | } |
||||
| 56 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.