Add Prop and ModelPropValue models with relationships; create migration files for props, prop options, prop data types, and model prop values
This commit is contained in:
38
app/Domains/Prop/Models/ModelPropValue.php
Normal file
38
app/Domains/Prop/Models/ModelPropValue.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Prop\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
#[Fillable([
|
||||
'valuable_type',
|
||||
'valuable_id',
|
||||
'prop_codigo',
|
||||
'value',
|
||||
])]
|
||||
class ModelPropValue extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'model_prop_values';
|
||||
|
||||
/**
|
||||
* @return MorphTo<Model, $this>
|
||||
*/
|
||||
public function valuable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Prop, $this>
|
||||
*/
|
||||
public function prop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Prop::class, 'prop_codigo', 'codigo');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user