ldc-qrcollector-back/app/Models/Brand.php

72 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2023-03-20 09:19:26 +00:00
<?php
namespace App\Models;
use App\Traits\Models\ActivityLog;
2023-03-20 09:19:26 +00:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2026-04-08 09:42:05 +02:00
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
2023-03-20 09:19:26 +00:00
class Brand extends Model
{
use HasFactory;
use ActivityLog;
2023-03-20 09:19:26 +00:00
/**
* The attributes that are mass assignable.
*
2026-02-12 16:09:21 +01:00
* @var list<string>
2023-03-20 09:19:26 +00:00
*/
protected $fillable = [
'name'
];
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function boot(): void
{
parent::boot();
static::deleting(function (self $model) {
$model->users()->detach();
});
}
// * RELATIONSHIPS
2023-03-20 09:19:26 +00:00
/**
* Get the urls for the brand.
*
2026-02-12 16:09:21 +01:00
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Url, $this>
2023-03-20 09:19:26 +00:00
*/
public function urls()
{
return $this->hasMany(Url::class);
}
/**
* Get the urls for the brand.
*
2026-02-12 16:09:21 +01:00
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Service, $this>
*/
public function services()
{
return $this->hasMany(Service::class);
}
2026-04-08 09:42:05 +02:00
/**
* The users that belong to the brand.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\User,
* $this,
* \Illuminate\Database\Eloquent\Relations\Pivot>
*/
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
2023-03-20 09:19:26 +00:00
}