fix filtering dealer and data with base on user login, partial update precheck and postcheck schema and view
This commit is contained in:
72
app/Http/Controllers/Transactions/PrechecksController.php
Normal file
72
app/Http/Controllers/Transactions/PrechecksController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Precheck;
|
||||
use App\Models\Transaction;
|
||||
|
||||
class PrechecksController extends Controller
|
||||
{
|
||||
public function index(Transaction $transaction)
|
||||
{
|
||||
$acConditions = Precheck::getAcConditionOptions();
|
||||
$blowerConditions = Precheck::getBlowerConditionOptions();
|
||||
$evaporatorConditions = Precheck::getEvaporatorConditionOptions();
|
||||
$compressorConditions = Precheck::getCompressorConditionOptions();
|
||||
|
||||
return view('transaction.prechecks', compact(
|
||||
'transaction',
|
||||
'acConditions',
|
||||
'blowerConditions',
|
||||
'evaporatorConditions',
|
||||
'compressorConditions'
|
||||
));
|
||||
}
|
||||
|
||||
public function store(Request $request, Transaction $transaction)
|
||||
{
|
||||
$request->validate([
|
||||
'kilometer' => 'required|numeric|min:0',
|
||||
'pressure_high' => 'required|numeric|min:0',
|
||||
'pressure_low' => 'nullable|numeric|min:0',
|
||||
'cabin_temperature' => 'nullable|numeric',
|
||||
'cabin_temperature_image' => 'nullable|string',
|
||||
'ac_condition' => 'nullable|in:' . implode(',', Precheck::getAcConditionOptions()),
|
||||
'ac_image' => 'nullable|string',
|
||||
'blower_condition' => 'nullable|in:' . implode(',', Precheck::getBlowerConditionOptions()),
|
||||
'blower_image' => 'nullable|string',
|
||||
'evaporator_condition' => 'nullable|in:' . implode(',', Precheck::getEvaporatorConditionOptions()),
|
||||
'evaporator_image' => 'nullable|string',
|
||||
'compressor_condition' => 'nullable|in:' . implode(',', Precheck::getCompressorConditionOptions()),
|
||||
'precheck_notes' => 'nullable|string',
|
||||
'front_image' => 'required|string',
|
||||
]);
|
||||
|
||||
// Pastikan transaction_id sama dengan $transaction->id
|
||||
$precheck = Precheck::create([
|
||||
'transaction_id' => $transaction->id,
|
||||
'precheck_by' => auth()->id(),
|
||||
'precheck_at' => now(),
|
||||
'police_number' => $transaction->police_number,
|
||||
'spk_number' => $transaction->spk,
|
||||
'front_image' => $request->front_image,
|
||||
'kilometer' => $request->kilometer,
|
||||
'pressure_high' => $request->pressure_high,
|
||||
'pressure_low' => $request->pressure_low,
|
||||
'cabin_temperature' => $request->cabin_temperature,
|
||||
'cabin_temperature_image' => $request->cabin_temperature_image,
|
||||
'ac_condition' => $request->ac_condition,
|
||||
'ac_image' => $request->ac_image,
|
||||
'blower_condition' => $request->blower_condition,
|
||||
'blower_image' => $request->blower_image,
|
||||
'evaporator_condition' => $request->evaporator_condition,
|
||||
'evaporator_image' => $request->evaporator_image,
|
||||
'compressor_condition' => $request->compressor_condition,
|
||||
'precheck_notes' => $request->precheck_notes,
|
||||
]);
|
||||
|
||||
return redirect()->route('transaction')->with('success', 'Precheck berhasil disimpan');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user