• 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

Laravel 5 issue with wherePivot

How to get variable from JavaScript to PHP [duplicate]

Filter WooCommerce related products by Polylang language

Assign output of PHP function to a variable

Laravel phpunit test failing authorization

500 (Internal Server Error) with Laravel & Docker [duplicate]

How to create custom authentication in laravel 8?

Problems getting instance of UploadedFile in Yii2

Laravel Displaying image from database

Laravel Model save() & update() Not Saving

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

Laravel Database Strict Mode

shell errors running php exec

Facebook PHP SDK - will not logout properly

Multiply each value in array using array_map function

About Contact Privacy policy Terms and conditions