kriszpchicken's avatar

Validate create form

I am creating a library application and I have a function, where the user can rent out books. The user can choose the book and the person who rents the book out. However, I want to validate it so, that no empty values can go through, so I want to make it required, but I am not sure how to write the code.

My Controller:

public function store(Request $request)
    {
       
        $reader = Reader::find($request->reader_id);
        $reader
            ->books()
            ->attach(
                $request->book_id,
                ["maxreturndate" => Carbon::now()->addDays(14)]
            );

        return redirect('checkedouts')->with('success', 'Buch wurde erfolgreich verliehen!');
    }
0 likes
1 reply

Please or to participate in this conversation.