mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Change to firstOrFail() for route model binding
This commit is contained in:
parent
ef08afc240
commit
b25f2b72a0
@ -37,7 +37,7 @@ class Client extends BaseModel
|
||||
'shipping_country'
|
||||
];
|
||||
|
||||
protected $with = ['contacts', 'primary_contact', 'country', 'shipping_country'];
|
||||
protected $with = ['contacts', 'primary_contact', 'country', 'shipping_country', 'company'];
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'object'
|
||||
|
@ -30,52 +30,52 @@ class RouteServiceProvider extends ServiceProvider
|
||||
|
||||
Route::bind('client', function ($value) {
|
||||
$client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
$client->with('contacts', 'primary_contact','country');
|
||||
// $client->with('contacts', 'primary_contact','country');
|
||||
return $client;
|
||||
});
|
||||
|
||||
Route::bind('invoice', function ($value) {
|
||||
return \App\Models\Invoice::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Invoice::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('payment', function ($value) {
|
||||
return \App\Models\Payment::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Payment::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('product', function ($value) {
|
||||
return \App\Models\Product::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Product::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('company', function ($value) {
|
||||
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('account', function ($value) {
|
||||
return \App\Models\Account::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Account::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('client_contact', function ($value) {
|
||||
return \App\Models\ClientContact::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\ClientContact::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('expense', function ($value) {
|
||||
return \App\Models\Expense::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Expense::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('invitation', function ($value) {
|
||||
return \App\Models\Invitation::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Invitation::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('task', function ($value) {
|
||||
return \App\Models\Task::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Task::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('tax_rate', function ($value) {
|
||||
return \App\Models\TaxRate::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\TaxRate::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
Route::bind('proposal', function ($value) {
|
||||
return \App\Models\Proposal::where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
return \App\Models\Proposal::where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user