• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Passing a boolean value from checkbox in Laravel form

phplaravel


PHP Snippet 1:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected $casts = [
        'is_featured' => 'boolean',
        'is_place' => 'boolean',
    ];
}

PHP Snippet 2:

<input type="checkbox" name="is_featured" class="switch-input" value="1" {{ old('is_featured') ? 'checked="checked"' : '' }}/>

PHP Snippet 3:

$post->is_featured = $request->has('is_featured');

Related Snippets

SQLSTATE[HY000]: General error: 1 table posts has no column named *

how to sort by a custom appended relation to model

Symfony Mercure "Failed to send an update"

PHP Warning: Module already loaded in Unknown on line 0

Smarty if isset

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Laravel whole batch is cancelled if one Job fails

Require a class from another class - php

Unable to uninstall brew php from homebrew

Changing font color in javascript

Laravel Unknown Column 'updated_at'

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Why isn't my PHP exception working?

Trying to iterate over a mongodb cursor twice - failing

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

About Contact Privacy policy Terms and conditions