You've already forked Atomcms-edit
Fix session same_site to use env, fix Article model import, remove unused traits
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Compositions;
|
||||
|
||||
trait HasNotificationUrl
|
||||
{
|
||||
public function getNotificationUrl(): string
|
||||
{
|
||||
return route('articles.show', [$this->id, $this->slug]);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
trait HasCommonScopes
|
||||
{
|
||||
/**
|
||||
* Scope to get active records.
|
||||
*/
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get pending records.
|
||||
*/
|
||||
public function scopePending(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status', 'pending');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get ordered records.
|
||||
*/
|
||||
public function scopeOrdered(Builder $query, $column = 'order', $direction = 'asc'): Builder
|
||||
{
|
||||
return $query->orderBy($column, $direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get latest records.
|
||||
*/
|
||||
public function scopeLatest(Builder $query, $column = 'created_at'): Builder
|
||||
{
|
||||
return $query->orderBy($column, 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get records created today.
|
||||
*/
|
||||
public function scopeToday(Builder $query, $column = 'created_at'): Builder
|
||||
{
|
||||
return $query->whereDate($column, today());
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope to get records from the last days.
|
||||
*/
|
||||
public function scopeLastDays(Builder $query, $days, $column = 'created_at'): Builder
|
||||
{
|
||||
return $query->where($column, '>=', now()->subDays($days));
|
||||
}
|
||||
|
||||
/**
|
||||
* Default behavior scope (can be overridden).
|
||||
*/
|
||||
public function scopeDefaultBehavior(Builder $query): Builder
|
||||
{
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user