• 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: Why is my variable not being set while it's in the construct function of the controller?

How to get transaction details in notify_url page in paypal

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

how to get value from array in laravel

Utf8 encoding issue with Laravel

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

Substitute integers and dots with regex [duplicate]

Adding Multiple Custom Post Types in Wordpress

Sentry + Laravel: how to log an already catched Exception?

Required field only if another field has a value, must be empty otherwise

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

Laravel Delete and Update

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

How to Display Data in Yajra Datatables Laravel 7?

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

About Contact Privacy policy Terms and conditions