ldc-mesbr-app/app/Models/Basket.php
2023-11-24 15:09:54 +00:00

34 lines
691 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();
});
}
}