title: Passing a boolean value from checkbox in Laravel form
body: <p>I am trying to save boolean value when I create a new Post and then have it update the value if I update the Post. When I create a new Post and save, it persists to the database and I can even update it without issue.  I am just having a little trouble dealing with a checkbox boolean. This is my fist project in Laravel, which is part of my hurdle I'm sure.</p>
  
  <p><strong>schema</strong></p>
  
  <pre><code>...
  public function up()
      {
          Schema::create('posts', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;unsignedBigInteger('user_id');
              $table-&gt;string('title');
              $table-&gt;text('body')-&gt;nullable();
              $table-&gt;string('photo')-&gt;nullable();
              $table-&gt;boolean('is_featured')-&gt;nullable()-&gt;default(false);
              $table-&gt;boolean('is_place')-&gt;nullable()-&gt;default(false);
              $table-&gt;string('tag')-&gt;nullable()-&gt;default(false);
              $table-&gt;timestamps();
          });
  
          Schema::table('posts', function (Blueprint $table) {
              $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');
          });
      }
  ...
  </code></pre>
  
  <p><strong>PostController.php</strong></p>
  
  <pre><code>...
  public function store(Request $request)
      {
          $rules = [
              'title' =&gt; ['required', 'min:3'],
              'body' =&gt; ['required', 'min:5']
          ];
          $request-&gt;validate($rules);
          $user_id = Auth::id();
          $post = new Post();
          $post-&gt;user_id = $user_id;
          $post-&gt;is_featured = request('is_featured');
          $post-&gt;title = request('title');
          $post-&gt;body = request('body');
          $post-&gt;save();
  
          $posts = Post::all();
          return view('backend.auth.post.index', compact('posts'));
      }
  ...
  </code></pre>
  
  <p><strong>post/create.blade.php</strong></p>
  
  <pre><code>...
  &lt;input type="checkbox" name="is_featured" class="switch-input"
         value="{{old('is_featured')}}"&gt;
  ...
  </code></pre>