33 lines
797 B
PHP
33 lines
797 B
PHP
<?php
|
|
|
|
namespace Modules\MasterData\Models;
|
|
|
|
use App\Traits\HasPublicIdentifier;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Modules\ProjectManagement\Models\Project;
|
|
|
|
class MaterialGroup extends Model
|
|
{
|
|
use HasPublicIdentifier;
|
|
|
|
protected $fillable = ['name', 'description', 'status'];
|
|
|
|
public function materials(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Material::class, 'material_group_items')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function projects(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Project::class, 'project_material_groups')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('status', 'active');
|
|
}
|
|
}
|