• 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

Return new collection without modifying original collection

Wordpress wpdb->delete issue

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

How to get array values using foreach in laravel

How to make dot match newline characters using regular expressions

Woocommerce redirect after add-to-cart error

Implode array with array of glue strings

Create tags in laravel post publishing

401 Unauthorized only occurring on some pages in Laravel 8

MOODLE: What does it mean to aggregate h5p assets?

Phalcon: setStatusCode returns empty response

best way to store error messages in Laravel (session or variable)

The "client_reference_id" argument is not passed

How do I call Validator from a namespace with an already existing Validator class

calling server using nusoap with complextype

About Contact Privacy policy Terms and conditions