'I can't Use firstOrFail and withtrashed laravel
I have this query
$this->areas = Area::firstOrFail('id', $this->area_id)
->with('areaGroup', function ($query){
$query->withTrashed();
})->get();
My Area model has softdeletes and the migration too. All works ok, but If I have a deleted Area, I get this error:
No query results for model [App\Models\Area].
If I add withTrashed()
$this->areas = Area::withTrashed()->firstOrFail('id', $this->area_id)
->with('areaGroup', function ($query){
$query->withTrashed();
})->get();
I get this error
TypeError PHP 8.0.17 str_contains(): Argument #1 ($haystack) must be of type string, Closure given
How can I retrieve results without add WithTrashed to the model?
The model has SoftDeletes and the migration too.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
