dev-think-one /
laravel-periodic-notice
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace PeriodicNotice\Concerns; |
||||
| 4 | |||||
| 5 | use Illuminate\Database\Eloquent\Builder; |
||||
| 6 | use Illuminate\Database\Eloquent\Model; |
||||
| 7 | use Illuminate\Database\Eloquent\Relations\MorphMany; |
||||
| 8 | use PeriodicNotice\Models\PeriodicSentEntry; |
||||
| 9 | |||||
| 10 | /** |
||||
| 11 | * Trait related to sendable entity. |
||||
| 12 | */ |
||||
| 13 | trait InPeriodicNotice |
||||
| 14 | { |
||||
| 15 | 1 | public function notificationEntityTitle(): string |
|||
| 16 | { |
||||
| 17 | 1 | return $this->title ?? ''; |
|||
| 18 | } |
||||
| 19 | |||||
| 20 | 1 | public function notificationEntityWebUrl(): string |
|||
| 21 | { |
||||
| 22 | 1 | return url($this->slug ?? ''); |
|||
| 23 | } |
||||
| 24 | |||||
| 25 | 1 | public function notificationEntityDescription(): string |
|||
| 26 | { |
||||
| 27 | 1 | return $this->description ?? ''; |
|||
| 28 | } |
||||
| 29 | |||||
| 30 | 2 | public function periodicSentEntries(): MorphMany |
|||
| 31 | { |
||||
| 32 | 2 | return $this->morphMany(PeriodicSentEntry::class, 'sendable'); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 33 | } |
||||
| 34 | |||||
| 35 | 2 | public function scopeDoesntSentInPeriodicNotice(Builder $query, Model $receiver, string $group) |
|||
| 36 | { |
||||
| 37 | 2 | $query->whereDoesntHave( |
|||
| 38 | 2 | 'periodicSentEntries', |
|||
| 39 | 2 | function (Builder $query) use ($receiver, $group) { |
|||
| 40 | 2 | $query->group($group) |
|||
| 41 | 2 | ->where('receiver_type', '=', $receiver->getMorphClass()) |
|||
| 42 | 2 | ->where('receiver_id', '=', $receiver->getKey()); |
|||
| 43 | 2 | } |
|||
| 44 | 2 | ); |
|||
| 45 | } |
||||
| 46 | |||||
| 47 | public function scopeReleasedAfter(Builder $query, \DateTimeInterface|string $dateTime, string $group) |
||||
|
0 ignored issues
–
show
The parameter
$group 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. Loading history...
|
|||||
| 48 | { |
||||
| 49 | $query->where('created_at', '>=', $dateTime); |
||||
| 50 | } |
||||
| 51 | } |
||||
| 52 |