51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\QrCode\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Support\Str;
|
|
|
|
class QrCode extends Model
|
|
{
|
|
use SoftDeletes, HasFactory;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'payload' => 'array',
|
|
'style' => 'array',
|
|
'ulid' => 'string',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $model) {
|
|
if (empty($model->ulid)) {
|
|
$model->ulid = (string) Str::ulid();
|
|
}
|
|
});
|
|
}
|
|
|
|
protected static function newFactory(): \Database\Factories\QrCodeFactory
|
|
{
|
|
return \Database\Factories\QrCodeFactory::new();
|
|
}
|
|
|
|
public function workspace(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Domains\Workspace\Models\Workspace::class);
|
|
}
|
|
|
|
public function link(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Domains\Link\Models\Link::class);
|
|
}
|
|
|
|
public function creator(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
|
}
|
|
}
|