• 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

Creating command to backup MySql database in Laravel

Laravel Model save() & update() Not Saving

Undefined Array Key error when uploading image on php

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Access denied for user 'homestead'@'localhost' (using password: YES)

Adding reCAPTCHA v2 into my PHP file

Laravel print last executed SQL query with Query log

php curl_exec() Connection refused when retrieving a remote image

Laravel UUID generation

MySQL/PHP - Web Based Game -User specific inventory table or 1 giant table? Another option?

using random function but it's displaying duplicates

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

How to identify whether webp image is static or animated?

PHP mail function is sending blank message body

About Contact Privacy policy Terms and conditions