- Star (is_starred) and colored tags for services, customers, orders, invoices:
Markable trait, tags/taggables tables, PATCH administrator/marks/{type}/{key},
tag CRUD, list filters starred / tag_ids[]
- GET administrator/services accepts product_type (falls back to product type
for legacy rows without services.type)
- Mail campaigns: bulk cancel / retry failed / delete; cancelled campaigns are
skipped by SendMailCampaignRecipient
- POST administrator/settings/test-smtp sends a test email through the saved
mail transport
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models\Concerns;
|
|
|
|
use App\Models\Tag;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|
|
|
trait Markable
|
|
{
|
|
public function initializeMarkable(): void
|
|
{
|
|
$this->mergeCasts(['is_starred' => 'boolean']);
|
|
}
|
|
|
|
public function tags(): MorphToMany
|
|
{
|
|
return $this->morphToMany(Tag::class, 'taggable')->orderBy('tags.title');
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $filters
|
|
*/
|
|
public function scopeMarked(Builder $query, array $filters): Builder
|
|
{
|
|
$tagIds = array_values(array_filter(array_map('intval', (array) ($filters['tag_ids'] ?? []))));
|
|
|
|
return $query
|
|
->when(
|
|
filter_var($filters['starred'] ?? false, FILTER_VALIDATE_BOOL),
|
|
fn (Builder $q) => $q->where($this->qualifyColumn('is_starred'), true),
|
|
)
|
|
->when($tagIds, fn (Builder $q) => $q->whereHas('tags', fn (Builder $tags) => $tags->whereIn('tags.id', $tagIds)));
|
|
}
|
|
}
|