feat: Phase 2 - page CRUD, subscriber management, user management
This commit is contained in:
@@ -74,6 +74,7 @@ class PreregistrationPage extends Model
|
||||
public function isActive(): bool
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return $now->gte($this->start_date) && $now->lte($this->end_date);
|
||||
}
|
||||
|
||||
@@ -86,4 +87,20 @@ class PreregistrationPage extends Model
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lifecycle label for admin tables: before registration opens, open window, or after end.
|
||||
*/
|
||||
public function statusKey(): string
|
||||
{
|
||||
if ($this->isBeforeStart()) {
|
||||
return 'before_start';
|
||||
}
|
||||
|
||||
if ($this->isExpired()) {
|
||||
return 'expired';
|
||||
}
|
||||
|
||||
return 'active';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -34,4 +35,19 @@ class Subscriber extends Model
|
||||
{
|
||||
return $this->belongsTo(PreregistrationPage::class);
|
||||
}
|
||||
|
||||
public function scopeSearch(Builder $query, ?string $term): Builder
|
||||
{
|
||||
if ($term === null || $term === '') {
|
||||
return $query;
|
||||
}
|
||||
|
||||
$like = '%'.$term.'%';
|
||||
|
||||
return $query->where(function (Builder $q) use ($like): void {
|
||||
$q->where('first_name', 'like', $like)
|
||||
->orWhere('last_name', 'like', $like)
|
||||
->orWhere('email', 'like', $like);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user