• 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 to display a view on laravel 8 and not have a 404 NOT FOUND page?

Override default Auth routes in Laravel 7

how to check version of codeigniter framework?

Sum column values from multiple arrays

Debugging Stripe Webhook Event

How to show selected value using javascript in laravel

send email using gmail-api and google-api-php-client

How to validate Envato Purchase Code in PHP

Symfony Mercure "Failed to send an update"

woocommerce get_order_report_data to show order_item_id

ConstraintViolationListInterface to Exception in Symfony

How to remove from a multidimensional array all duplicate elements including the original?

Convert every two values of an associative array into key-value pairs

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

About Contact Privacy policy Terms and conditions