A
A
alex--n2019-12-20 15:23:01
Laravel
alex--n, 2019-12-20 15:23:01

How to remove append when link is loaded using with?

Hello!
There is a model, she has

class Model 
{
...
protected $appends = [
        'some_append',
        'some_append2',
    ];
...
}

There is a second model with a prescribed rileyshenom
class Model2
{
...
public function models(): BelongsToMany
    {
        return $this->belongsToMany(Model::class);
    }
...
}

Then I make a request in the controller. It, as it should, hooks these $appends. But I don't need them here and make unnecessary requests. I can’t delete it, because may break somewhere else. So is there any correct solution? PS I don’t want to contact the usual query builder, as a last resort)
$result = Model2::with('models')->get();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question