• 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 test laravel controller method?

How do I get friend list from Friends table with counts of friends of my friends

Input and output values for php into the browser?

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

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

Transform array, set each array element with parent key php

Laravel 5 controller sending JSON integer as string

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How to make autocomplete work in foreach php loop? (vscode, intellisense)

PHP password_verify

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

Laravel Delete and Update

How to install LDAP in Docker php-fpm alpine

Sagepay Error The Vendor failed to provide a RedirectionURL

Whats the point of running Laravel with the command 'php artisan serve'?

About Contact Privacy policy Terms and conditions