app/Http/Requests/Api/BookingRequest.php
/**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
Get the validation rules that apply to the request.
@return array
Get the validation rules that apply to the request . @return array
public function rules()
    {
        if ($this->routeIs('booking.book')) {
            return [
                'pickup_station_id' => ['required', 'exists:stations,id'],
                'arrival_station_id' => ['required', 'exists:stations,id'],
                'seat_number' => ['required', 'numeric']
            ];
        }
        if ($this->routeIs('booking.available')) {
            return [
                'pickup_station_id' => ['required', 'exists:stations,id'],
                'arrival_station_id' => ['required', 'exists:stations,id'],
            ];
        }
    }
public function rules ( ) { if ( $ this -> routeIs ( 'booking.book' ) ) { return [ 'pickup_station_id' => [ 'required' , 'exists:stations,id' ] , 'arrival_station_id' => [ 'required' , 'exists:stations,id' ] , 'seat_number' => [ 'required' , 'numeric' ] ] ; } if ( $ this -> routeIs ( 'booking.available' ) ) { return [ 'pickup_station_id' => [ 'required' , 'exists:stations,id' ] , 'arrival_station_id' => [ 'required' , 'exists:stations,id' ] , ] ; } }
Get the validation rules that apply to the request.
Get the validation rules that apply to the request .