I need to get model with its relation, but this relation pull their relations which I dont want to have in result. So I tried to use Model::witout() where I used dot notation like in with() clasuse. The code looks like:
$receipt = Receipt::where('id', '=', $receiptId)
->with(['company', 'currency', 'receiptLink', 'receiptPoint',
'customer' => function ($query) {
$query->select('id', 'name'); // Or whatever fields you need from the customer
},
])->first();
It seems is is bacause $appends array contains accessor named "receipts_parsed" which loads all the receipts and returns parsed value. How can I remove the accessor to be loaded if it is mentioned in $appends array?
@Čamo accessors can be used even if they are not in the $appends array. (as long as they are public)
All appends does is ALWAYS include an accessor in the model, it's up to you to decide if you want that accessor to always be included or not.