• 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 fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Get sum of arrays inside array

WAMP Virtual Host not working

What is the difference between client-side and server-side programming?

Destroy session upon refresh

Laravel Unknown Column 'updated_at'

How to retrieve Active Directory group policy maximum password age using LDAP

enable Apache http Authorization header

PHP using str_starts_with for array to exclude same as with wildcard

How do I upload a laravel project on cPanel shared hosting?

Install mysql client in docker image

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

Laravel s3 upload file with metadata using pre-signed url

MySQL upgrade causing unexpected results on simple WHERE clauses

Explain how this array transposing and flattening function works

About Contact Privacy policy Terms and conditions