small fixes
parent
db4f29d0f7
commit
79ac1dcda3
|
|
@ -132,6 +132,7 @@ class ContractController extends Controller
|
|||
{
|
||||
$contract = Contract::create(
|
||||
$request->validate([
|
||||
'type' => ['required'],
|
||||
'date' => ['required', 'date'],
|
||||
'price' => ['required', 'integer'],
|
||||
'car_id' => ['required', 'exists:App\Models\Car,id'],
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ class Contract extends Model
|
|||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo(Contact::class);
|
||||
return $this->belongsTo(Contact::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function car()
|
||||
{
|
||||
return $this->belongsTo(Car::class);
|
||||
return $this->belongsTo(Car::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function scopeThisYear($query)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Models\Car;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Contract;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
|
@ -56,6 +57,13 @@ class RouteServiceProvider extends ServiceProvider
|
|||
return Car::find($value);
|
||||
});
|
||||
|
||||
Route::bind('contact', function ($value) {
|
||||
if (in_array(Route::currentRouteName(), ['contacts.show', 'contacts.restore'])) {
|
||||
return Contact::withTrashed()->find($value);
|
||||
}
|
||||
return Contact::find($value);
|
||||
});
|
||||
|
||||
Route::bind('contract', function ($value) {
|
||||
if (in_array(Route::currentRouteName(), ['contracts.show', 'contracts.restore'])) {
|
||||
return Contract::withTrashed()->find($value);
|
||||
|
|
|
|||
|
|
@ -19528,7 +19528,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
id: null,
|
||||
date: null,
|
||||
price: null,
|
||||
type: this.type,
|
||||
type: this.type == "SellContract" ? 0 : 1,
|
||||
insurance_type: '0',
|
||||
car_id: this.car.id,
|
||||
contact_id: this.contact.id
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default {
|
|||
id: null,
|
||||
date: null,
|
||||
price: null,
|
||||
type: this.type,
|
||||
type: this.type == "SellContract" ? 0 : 1,
|
||||
insurance_type: '0',
|
||||
car_id: this.car.id,
|
||||
contact_id: this.contact.id,
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ Route::put('contacts/{contact}', [ContactController::class, 'update'])
|
|||
->name('contacts.update')
|
||||
->middleware(['auth:sanctum', 'verified']);
|
||||
|
||||
Route::delete('contacts/{contact}', [ContactController::class, 'destroy'])
|
||||
Route::get('contacts/{contact}/delete', [ContactController::class, 'destroy'])
|
||||
->name('contacts.destroy')
|
||||
->middleware(['auth:sanctum', 'verified']);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue