• 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 check version of codeigniter framework?

PHP only Hit Counter?

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Laravel Schedule not sending email

How to install php yaml on CentOs?

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Cut an arabic string

how to upload binary image to sql server using php laravel

Doctrine 2 mapping referencing unique key

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

Show Custom Data in Woocommerce Order Details Admin Area

Component install error: JInstaller: :Install: File does not exist

how to remove white space in select 2

enable Apache http Authorization header

Filter array by skipping every nth element from the end

About Contact Privacy policy Terms and conditions