• 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 Schedule not sending email

How To Access A Column In M-M Relationship Table In Laravel

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

WHERE IN array binding in DB::raw laravel 5.4

Laravel implode array items to new lines

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

dockerizing Laravel + vue

How to fix Call to undefined method AppModelsTableName::factory?

PHP Get value from JSON [duplicate]

Add bold text and line break into Laravel Notification Email

how can I set a session variable in Drupal 8 and get it in a php script?

Render the content of default_filter.php in Joomla front-end

Last order would be re-order in wooCommerce. How is it possible?

Parameter is not sent to Laravel route in Ajax

Natural ORDER in Laravel Eloquent ORM

About Contact Privacy policy Terms and conditions