• 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

Extract string between first whitespace and last whitespace in php

PDOException SQLSTATE[HY000] [2002] No such file or directory

How to redirect to another page and call a Function there on Angular ng-click

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

How to identify whether webp image is static or animated?

PHP to search within txt file and echo the whole line

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Edit product hook WooCommerce

MySQL upgrade causing unexpected results on simple WHERE clauses

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

Android Volley getParams() method not getting called for JsonObjectRequest

How do I do HTTP basic authentication using Guzzle?

Laravel Factory not calling callback 'afterCreating'

file_put_content...fail to open stream:Permission denied in Laravel 5

PHPUnit (Phar) Fatal Error Only When Test Fails

About Contact Privacy policy Terms and conditions