StoreTestTransactionRequest.php 968B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Requests\TestTransaction;
  3. use App\Models\EntryTransaction;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rule;
  6. class StoreTestTransactionRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. *
  11. * @return bool
  12. */
  13. public function authorize()
  14. {
  15. return true;
  16. }
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array<string, mixed>
  21. */
  22. public function rules()
  23. {
  24. if ($this->id === 2) {
  25. return [
  26. 'plat_number' => 'required',
  27. 'entry_transaction_id' => [
  28. 'required',
  29. Rule::in(EntryTransaction::pluck('transaction_number')),
  30. ],
  31. 'type_vehicle_id' => 'required',
  32. ];
  33. } else {
  34. return [
  35. //
  36. ];
  37. }
  38. }
  39. }