Answer the question
In order to leave comments, you need to log in
Is it possible to create a custom link?
For example, instead of this, in the Order model
public function order
{
return $this->belongsTo('App\Order');
}
public function order
{
return self::query()->where('cost', '>', $this->cost);
}
Answer the question
In order to leave comments, you need to log in
I solved the issue by implementing a custom method that adds a link to the collection of models.
Transmitted in a completely different way
public function relatedOrders()
{
return $this->hasMany(self::class, "parent_id", "id")->fromHighPriceOrders();
}
I think I understand...
Reading about scope's
public function scopeCost($query,$value)
{
return $query->where('cost', '>', $value);
}
$data = Order::cost(100)->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question