ldc-mesbr-app/app/Models/Basket.php
Nicolas Demangeat 9f30e3243d CRUD brand
2023-09-13 16:48:17 +02:00

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