• 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 set a domain name with php artisan serve

Unable to uninstall brew php from homebrew

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

WHM Enabling mod_rewrite

How to get Laravel's CSRF Token from Another Website?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

How to change product Image when variables are selected in Shop and Archive Pages?

how to remove %20 in the url in php

Laravel/docker-compose/redis - Class 'Redis' not found

PHP Slim Framework request using withAttribute error

Laravel Collections. Is there some kind of assertStructure method?

How to render html from a @foreach loop in a textarea

Custom add to cart button URL for specific product in WooCommerce?

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

About Contact Privacy policy Terms and conditions