• 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 get the total hour from starting time to end time in php

How can i update or reset my password without entering email field in laravel-8?

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

How to submit the custom form data in database in WordPress without plugin using ajax?

WordPress Subquery returns more than 1 row on SELECT

Server-sent events in PHP (without echo or print)

No definition found for function in vendor vscode

Laravel Jetsream Profile page not loading on fresh install

Convert date and time to Jalali in Laravel

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

disable two buttons after clicking another button

dockerizing Laravel + vue

MySQL upgrade causing unexpected results on simple WHERE clauses

Elastic Beanstalk with Laravel Envoy

Cache clear probem in Larave

About Contact Privacy policy Terms and conditions