• 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

Using Associative arrays

Smarty if isset

Don't show recurring price for WooCommerce subscriptions worth 0$

Laravel You requested 1 items, but there are only 0 items available

WAMP Virtual Host not working

Remove categories with all childs derived from parent category

Laravel 5.5 change unauthenticated login redirect url

nginx err_connection_refused, can anyone help me?

How can I access an array/object?

PHP: Print caught exception like Xdebug

Laravel insert dynamic input values with radio button

Additional price based on cart item count in WooCommerce

Laravel Collections. Is there some kind of assertStructure method?

laravel 5.6 bulk inserting json data

Wordpress 'post_type_link' hides permalink

About Contact Privacy policy Terms and conditions