• 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

Open a popup box after receiving result from ajax

Performance of foreach, array_map with lambda and array_map with static function

Connecting an HTML webpage to a SQL Server

XDebug not working in VScode for php debugging

PHP using str_starts_with for array to exclude same as with wildcard

Laravel eloquent update record without loading from database

Laravel 5 controller sending JSON integer as string

PHP mail sending empty mails

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How to validate Envato Purchase Code in PHP

How to get unique slug to same post-title for other time too?

Laravel - How to properly generate unique slugs from article titles?

Symfony autowiring issues since docker update

Ajax GET request fails in laravel 8

About Contact Privacy policy Terms and conditions