10 months ago

Cleaner Controllers

Posted 10 months ago by jhutto

I recently watched the Laravel 5.7 From Scratch - Cleaner Controllers and Mass Assignment Concerns Video

And I started working on cleaning up my controllers. Then I ran into this one.


How do I get check boxes into this format......

Instructor::update(request(['FirstName', 'LastName']));

Here's my current update function (condensed of course)

$instructor = \App\Instructor::find($id);
        $instructor->FirstName = $request->FirstName;
        $instructor->LastName = $request->LastName;

        if (!$request->has('Viewable'))
            // Checkbox is checked
            $instructor->Active = "0";
             // Checkbox is not checked
             $instructor->Active = "1";



Please sign in or create an account to participate in this conversation.