73 lines
3.1 KiB
PHP
73 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Transactions;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Postcheck;
|
|
use App\Models\Transaction;
|
|
|
|
class PostchecksController extends Controller
|
|
{
|
|
public function index(Transaction $transaction)
|
|
{
|
|
$acConditions = Postcheck::getAcConditionOptions();
|
|
$blowerConditions = Postcheck::getBlowerConditionOptions();
|
|
$evaporatorConditions = Postcheck::getEvaporatorConditionOptions();
|
|
$compressorConditions = Postcheck::getCompressorConditionOptions();
|
|
|
|
return view('transaction.postchecks', 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(',', Postcheck::getAcConditionOptions()),
|
|
'ac_image' => 'nullable|string',
|
|
'blower_condition' => 'nullable|in:' . implode(',', Postcheck::getBlowerConditionOptions()),
|
|
'blower_image' => 'nullable|string',
|
|
'evaporator_condition' => 'nullable|in:' . implode(',', Postcheck::getEvaporatorConditionOptions()),
|
|
'evaporator_image' => 'nullable|string',
|
|
'compressor_condition' => 'nullable|in:' . implode(',', Postcheck::getCompressorConditionOptions()),
|
|
'postcheck_notes' => 'nullable|string',
|
|
'front_image' => 'required|string',
|
|
]);
|
|
|
|
// Pastikan transaction_id sama dengan $transaction->id
|
|
$postcheck = Postcheck::create([
|
|
'transaction_id' => $transaction->id,
|
|
'postcheck_by' => auth()->id(),
|
|
'postcheck_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,
|
|
'postcheck_notes' => $request->postcheck_notes,
|
|
]);
|
|
|
|
return redirect()->route('transaction')->with('success', 'Postcheck berhasil disimpan');
|
|
}
|
|
}
|