Initial Commit
This commit is contained in:
commit
ddf09fe00c
113 changed files with 187148 additions and 0 deletions
60
app/Models/Setting.php
Normal file
60
app/Models/Setting.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory, Prunable;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $fillable = [
|
||||
'value',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'value' => Casts\GameSettingsCaster::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the prunable model query.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function prunable()
|
||||
{
|
||||
return static::where('created_at', '<', now()->subDay(1));
|
||||
}
|
||||
|
||||
public function getHashAttribute()
|
||||
{
|
||||
return Hashids::encode($this->id);
|
||||
}
|
||||
|
||||
public function scopeHash($q, $hash)
|
||||
{
|
||||
return $q->where('id', Hashids::decode($hash));
|
||||
}
|
||||
|
||||
/*
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if ($method == 'find' && is_string($parameters[0])) {
|
||||
$parameters[0] = Hashids::decode($$parameters[0]);
|
||||
}
|
||||
|
||||
return parent::__call($method, $parameters);
|
||||
} */
|
||||
}
|
||||
Reference in a new issue