• 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

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Attempt to read property "view" on null when sending password reset email

Unable to get password for the instance created from AMI

Convert regular text to array using notepad++

php curl_exec() Connection refused when retrieving a remote image

PHP/HTML: Creating A SubMenu

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

Sentry + Laravel: how to log an already catched Exception?

Laravel php artisan serve to mimic HTTPS

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

Laravel csrf token mismatch for ajax POST Request

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Problem with fetching data from database in Laravel

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

Yii2 redirecting to previous page after login

About Contact Privacy policy Terms and conditions