Laravel return empty relationship on model when condition is true code example
Example: Laravel return empty relationship on model when condition is true
public function shop(): BelongsTo
{
if(true) {
return new BelongsTo($this->newQuery(), $this, '', '', '');
}
return $this->belongsTo('App\Models\Shop');
}