• 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 get quarter for future date using Carbon?

How to change HTML structure inside WP <head>

Converting IPv6 to IPv4 address in PHP

Insert a DIV after the 6th product only once in WooCommerce category archives

java URL working on browser but not in client program

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

ConstraintViolationListInterface to Exception in Symfony

Call authenticate manually in router middleware

image source not readable

How to Make Laravel Eloquent "IN" Query?

protect my blog content

Alert message after submitting form in PHP

Reading input in php from terminal

How to put php code inside opening and closing shortcodes

Issue with laravel eloquent model property

About Contact Privacy policy Terms and conditions