34 lines
692 B
PHP
34 lines
692 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Basket extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'reference',
|
|
'customer_id',
|
|
'campaign_id'
|
|
];
|
|
|
|
public function content() : HasMany
|
|
{
|
|
return $this->hasMany(BasketsContent::class);
|
|
}
|
|
|
|
/**
|
|
* The "booted" method of the model.
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (Basket $basket) {
|
|
$basket->reference = Str::ulid();
|
|
});
|
|
}
|
|
}
|