• 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

selected value from the listbox in php

Fetch files from next cloud storage and display in Laravel website

Can we define variables in `.tpl` files?

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

How can I get user id from session in javascript?

Prestashop webservice API creating cart rules

MySQL - Connection failed: No route to host

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

Get number of working days between two dates in PHP [duplicate]

How To Access A Column In M-M Relationship Table In Laravel

How to remove from a multidimensional array all duplicate elements including the original?

Yii2 redirecting to previous page after login

Combining a describing and one array with data

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

About Contact Privacy policy Terms and conditions