• 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

Unit (real unit test) of test laravel relationship

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

array_key_exists(): The first argument should be either a string or an integer

How to programmatically find public properties of a class from inside one of it's methods

Use Python plotly chart in PHP

how to validate form data in codeigniter 4

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

PHP my timezone is no setting up in PHP.ini File in xampp

Laravel insert dynamic input values with radio button

Make survey at laravel 5.4 and MySQL

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

HTML + PHP + PHPMAILER

Composer Warning: openssl extension is missing. How to enable in WAMP

"There is no active transaction" when refreshing database in Laravel 8.0 test

Explain how this array transposing and flattening function works

About Contact Privacy policy Terms and conditions