• 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

Method IlluminateAuthRequestGuard::logout does not exist Laravel Passport

How to properly start Laravel 8 with Bootstrap & authentication

How to upload mpdf file after generating to s3 bucket in php

Using spatie/media-library, how to rename a collection of uploaded files?

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Filter array by skipping every nth element from the end

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

Calculating Median of an array in PHP

Getting public posts of a random user from Facebook API

add uri parameter to Route name in laravel

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

could not find driver Debian SQL Server PHP

get folder directory from input type file - PHP

Symfony run hint kernel.secret parameter not found

PhP how to calculate moments with variables rows

About Contact Privacy policy Terms and conditions