feat(mailbox): Implement cinematic UX and user tiers
- Added Spatie roles (free, pro, enterprise, admin) and access scopes - Implemented delayed, cinematic mailbox provisioning animation - Fixed GSAP and SVG collision issues on creation overlay - Improved component sync with livewire refresh - Added feature tests for tier systems and fixed RegistrationTest
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -41,4 +42,27 @@ class Domain extends Model
|
||||
{
|
||||
return $this->hasMany(Mailbox::class, 'domain_hash', 'domain_hash');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to domains accessible by the given user tier.
|
||||
* For guests (null user), only 'public' domains are returned.
|
||||
*
|
||||
* Uses MySQL's JSON_CONTAINS to check if the domain's `allowed_types`
|
||||
* array includes ANY of the user's allowed types.
|
||||
*
|
||||
* Usage:
|
||||
* Domain::accessibleBy(auth()->user())->get(); // logged-in
|
||||
* Domain::accessibleBy(null)->get(); // guest
|
||||
* Domain::accessibleBy($user)->where('is_active', true)->get();
|
||||
*/
|
||||
public function scopeAccessibleBy(Builder $query, ?User $user = null): Builder
|
||||
{
|
||||
$types = $user ? $user->allowedDomainTypes() : User::guestDomainTypes();
|
||||
|
||||
return $query->where(function (Builder $q) use ($types) {
|
||||
foreach ($types as $type) {
|
||||
$q->orWhereJsonContains('allowed_types', $type);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user