• 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

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

How avoid Moved Permanently The document has moved here

PHP rotate matrix counter-clockwise

laravel and phpunit: could not find driver (SQL: PRAGMA foreign_keys = ON;)

Send Outlook 2010 email using PHP

Assets not referencing to public folder (Laravel)

How can I resolve "Your requirements could not be resolved to an installable set of packages" error?

Adding hreflang tags automatically in WordPress subdirectory multisite

Prevent blank space in pdf pages (DomPdf)

Laravel multi auth - Authentication user provider [] is not defined

Issue saving card for customer

best way to store error messages in Laravel (session or variable)

CONCAT columns with Laravel 5 eloquent

send email using gmail-api and google-api-php-client

Laravel 5.2: Unable to locate factory with name [default]

About Contact Privacy policy Terms and conditions