• 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 fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How to get variable from JavaScript to PHP [duplicate]

how to hide previous markers when new markers added in google map javascript api

Class AppHttpControllersUserController Does Not Exist

how to fix Service provider class not found when using repository?

Having trouble with PDO queries (Notice: Undefined index)

Laravel Model save() & update() Not Saving

Remove country code from phone number?

Wordpress add responsive srcset header image to theme

How to unlink image from folder?

Require a class from another class - php

how to prevent float variables displaying as scientific notation when printing [duplicate]

find in set in laravel ? example

Why does using salted hash on python and php give me different results?

how to create html table in php

About Contact Privacy policy Terms and conditions