Initial commit with contrats and domaines modules
This commit is contained in:
35
app/Models/Article.php
Normal file
35
app/Models/Article.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'reference', 'designation', 'description',
|
||||
'categorie_id', 'fournisseur_id', 'prix_unitaire_ht', 'unite', 'active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'prix_unitaire_ht' => 'decimal:2',
|
||||
'active' => 'boolean',
|
||||
];
|
||||
|
||||
public function categorie(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Categorie::class);
|
||||
}
|
||||
|
||||
public function fournisseur(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fournisseur::class);
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('active', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user