Refactor Brand, Category, Product, and ModelPropValue models to remove morph relationships; update migration files for props and model prop values to reflect new foreign key structure.
This commit is contained in:
@@ -6,12 +6,10 @@ 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',
|
||||
'prop_id',
|
||||
'value',
|
||||
])]
|
||||
class ModelPropValue extends Model
|
||||
@@ -20,19 +18,11 @@ class ModelPropValue extends Model
|
||||
|
||||
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');
|
||||
return $this->belongsTo(Prop::class, 'prop_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user