app/Http/Controllers/AttendanceController.php
/**
     * Store a newly created resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     * @return AttendanceResource
     * @throws \Illuminate\Validation\ValidationException
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $accountID = trim($request->account_id);
        $input = [
            "account_id" => $accountID,
        ];
        $rules = [
            "account_id" => "required|integer|exists:accounts,id",
        ];
        Validator::make(
            $input,
            $rules,
            $messages = [
                "required" =>
                    "The :attribute field is required for marking the attendance",
                "integer" => "The :attribute field should be a valid account.",
            ]
        )->validate();
        try {
            $attendance = AttendanceService::createInAttendance($request);
            return new AttendanceResource($attendance);
        } catch (\Exception $exception) {
            return Helper::exceptionJSON($exception, 422, "attendance");
        }
    }
public function store ( Request $ request ) { $ accountID = trim ( $ request -> account_id ) ; $ input = [ " account_id " => $ accountID , ] ; $ rules = [ " account_id " => " required|integer|exists:accounts,id " , ] ; Validator :: make ( $ input , $ rules , $ messages = [ " required " => " The :attribute field is required for marking the attendance " , " integer " => " The :attribute field should be a valid account. " , ] ) -> validate ( ) ; try { $ attendance = AttendanceService :: createInAttendance ( $ request ) ; return new AttendanceResource ( $ attendance ) ; } catch ( \ Exception $ exception ) { return Helper :: exceptionJSON ( $ exception , 422 , " attendance " ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .