ldc-mesbr-app/app/Models/Basket.php
Vincent BRIDIER 80dbb04671
PHPCS
2023-11-24 15:35:08 +01:00

46 lines
907 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;
/**
* Fillable
*
* @var string[]
*/
protected $fillable = [
'reference',
'customer_id',
'campaign_id'
];
/**
* Get the content owned by the Basket
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function content(): HasMany
{
return $this->hasMany(BasketsContent::class);
}
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function booted(): void
{
static::creating(function (Basket $basket) {
$basket->reference = Str::ulid();
});
}
}