• 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

What will the best solution for this multiple optional filter?

Laravel Database Strict Mode

codeigniter 4 running error first time with xampp

str_replace or preg_replace random number from string

How to get the total hour from starting time to end time in php

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

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

How can i hide dt if dd got empty value

Login if user is active using Laravel Breeze

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Cannot connect to own websocket server when on secured domain

How to create laravel storage symbolic link for production or sub domain system?

laravel sanctum Route [login] not defined

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

About Contact Privacy policy Terms and conditions