You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\User;
|
||||
|
||||
use App\Models\Concerns\BelongsToUser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|UserOrder latest($column = 'created_at')
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|UserOrder pending()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|UserOrder cancelled()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|UserOrder completed()
|
||||
*/
|
||||
class UserOrder extends Model
|
||||
{
|
||||
use BelongsToUser;
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'status', 'amount'];
|
||||
|
||||
#[\Override]
|
||||
public $timestamps = true;
|
||||
|
||||
public const STATUS_PENDING = 'pending';
|
||||
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
|
||||
public const STATUS_CANCELLED = 'cancelled';
|
||||
|
||||
public function scopePending($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_PENDING);
|
||||
}
|
||||
|
||||
public function scopeCompleted($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
public function scopeCancelled($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
public function scopeLatest($query)
|
||||
{
|
||||
return $query->orderBy('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user