• 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

IlluminateDatabaseQueryException could not find driver [duplicate]

What will the best solution for this multiple optional filter?

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

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

How to get AJAX to post on second page?

how to insert data into select2 search input after scan using qrcode

PHP Warning: Module already loaded in Unknown on line 0

How to show a popup modal in codeIgniter?

Laravel Excel::store file empty after stored

Problem with fetching data from database in Laravel

Webscraping Symfony/Panther: Can't get HTML

VB.NET WebRequest with PHP POST

How Can I Do LIMIT 1, 2 In WP_Query

How to fix bootstrap multiselect search data using ajax

Merge key and value of array index [duplicate]

About Contact Privacy policy Terms and conditions