Support the ongoing development of Laravel.io →
Database Forms Validation
Last updated 2 years ago.
0

I got Laravel to work at last. There's probably a smarter way but in the validator method I use the array $data, and in the create method - the Request $request. Don't forget to namespace both the validator and the request into the controller

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'content' => 'required'
        ]);
    }

    protected function create(Request $request)
    {
        return Comment::create([
            'user_id' => Auth::user()->id,
            'content' => nl2br($request->input('content'))
        ]);
    }
0

Sign in to participate in this thread!

Eventy

Your banner here too?

muppbarn muppbarn Joined 29 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.