Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

@bodyParam in subclass #46

Open
wisnubaldas opened this issue Oct 10, 2024 · 1 comment
Open

@bodyParam in subclass #46

wisnubaldas opened this issue Oct 10, 2024 · 1 comment

Comments

@wisnubaldas
Copy link

hi,
I follow the notes

Note: You can also add the @bodyParam annotations to a \Illuminate\Foundation\Http\FormRequest subclass:

however this doesn't work on my document, can you tell me the error

App\Http\Requests\TPS\ThInboundRequest.php

namespace App\Http\Requests\TPS;

use Illuminate\Foundation\Http\FormRequest;

/**
 * @bodyParam tps string required tps data.
 * @bodyParam gate_type string required gate_type data in:import,incoming,transit.
 * @bodyParam waybill_smu string required waybill_smu data.
 * @bodyParam hawb string required hawb data.
 * @bodyParam koli string required koli data.
 * @bodyParam netto string required netto data.
 * @bodyParam volume string required volume data.
 * @bodyParam kindofgood string required kindofgood data.
 * @bodyParam airline_code string required airline_code data.
 * @bodyParam flight_no string required flight_no data.
 * @bodyParam origin string required origin data.
 * @bodyParam transit string required transit data.
 * @bodyParam dest string required dest data.
 * @bodyParam shipper_name string required shipper_name data.
 * @bodyParam consignee_name string required consignee_name data.
 * @bodyParam _is_active boolean required _is_active data.
 * @bodyParam full_check boolean required full_check data.
 * 
 */
class ThInboundRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'tps' => ['nullable', 'string', 'min:1', 'max:4'],
            'gate_type' => ['required', 'string', 'in:import,incoming,transit'],
            'waybill_smu' => ['nullable', 'string', 'min:1', 'max:15'],
            'hawb' => ['nullable', 'string', 'min:1', 'max:25'],
            'koli' => ['nullable', 'integer'],
            'netto' => ['nullable', 'numeric'],
            'volume' => ['nullable', 'numeric'],
            'kindofgood' => ['nullable', 'string', 'min:1', 'max:100'],
            'airline_code' => ['nullable', 'string', 'min:1', 'max:2'],
            'flight_no' => ['nullable', 'string', 'min:1', 'max:7'],
            'origin' => ['nullable', 'string', 'min:1', 'max:5'],
            'transit' => ['nullable', 'string', 'min:1', 'max:5'],
            'dest' => ['nullable', 'string', 'min:1', 'max:5'],
            'shipper_name' => ['nullable', 'string', 'min:1', 'max:120'],
            'consignee_name' => ['nullable', 'string', 'min:1', 'max:120'],
            '_is_active' => ['required', 'boolean'],
            '_created_by' => ['nullable', 'string', 'min:1', 'max:120'],
            '_updated_by' => ['nullable', 'string', 'min:1', 'max:120'],
            '_remarks_last_update' => ['nullable', 'string', 'min:1'],
            'key_upload' => ['nullable', 'integer'],
            'full_check' => ['required', 'boolean']
        ];
    }
}

App\Http\Controllers\api\Cont\CloudStatusController.php

namespace App\Http\Controllers\api\Cont;

use App\Http\Controllers\Controller;
use App\Repositories\Eloquent\TPS\ThInboundRepositoryEloquent;
use App\Http\Requests\TPS\ThInboundRequest;
/**
 * @group CloudStatusController
 * 
 */

class CloudStatusController extends Controller
{
    protected $inbound;
    public function __construct(ThInboundRepositoryEloquent $inbound)
    {
        $this->inbound = $inbound;
    }
    /**
     * All Cloud Status
     *
     * @responseFile responses/CloudStatus.index.json
     * 
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return $this->inbound->paginate(10);
    }

    /**
     * Create CloudStatus
     * 
     * @authenticated
     * @response {
     *      "status": 200,
     *      "success": true
     * }
     *
     * @param  ThInboundRequest  $request
     * 
     * @return \Illuminate\Http\Response
     */
    public function store(ThInboundRequest $request)
    {
        $request->validated();
        return $this->inbound->create($request->all());
    }
}

image

@Moemen02
Copy link

Did you find a solution? Im also having this issue

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants