• 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 redirect to another page after n seconds in wordpress without using javascript?

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

No result using makeStyles Material UI in react 18

Problem with fetching data from database in Laravel

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Message: Set sys_temp_dir in your php.ini after installed composer

Call authenticate manually in router middleware

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Can I write PHP code across multiple lines per statement?

Get data from accuweather api url

Image upload not working through ajax Laravel

Get WooCommerce products from specific category

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Can't find vendor/autoload.php for Ratchet

Navigation idle on content download

About Contact Privacy policy Terms and conditions