Initial commit with contrats and domaines modules
This commit is contained in:
32
app/Models/Categorie.php
Normal file
32
app/Models/Categorie.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Categorie extends Model
|
||||
{
|
||||
protected $fillable = ['nom', 'description', 'couleur', 'icone', 'ordre', 'active'];
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'boolean',
|
||||
'ordre' => 'integer',
|
||||
];
|
||||
|
||||
public function articles(): HasMany
|
||||
{
|
||||
return $this->hasMany(Article::class);
|
||||
}
|
||||
|
||||
public function lignesCommande(): HasMany
|
||||
{
|
||||
return $this->hasMany(LigneCommande::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user