• 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

Laravel Livewire: jQuery not working in child component loaded via @if statement

How to convert a carbon into string, to take the date only?

How to write PHP in XSLT

Fetch files from next cloud storage and display in Laravel website

PHP: How to solve ob_start() in combination imagepng() issue?

I need to link Google Sheet with my Laravel

Yii2: How to download backup files using spanjeta/yii2-backup?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Alert message after submitting form in PHP

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

Detect emoticons in string

PHP: Insert marker every 3 iterations

How to get monthly wise data in laravel

Wordpress add responsive srcset header image to theme

Session timeout in Yii2

About Contact Privacy policy Terms and conditions