• 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

Create a zip file and download it

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

How to unlink image from folder?

Laravel 8 Multiple Relationships for Factory

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

Session timeout in Yii2

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

WooCommerce: Add/display Product or Variation custom field everywhere

Getting public posts of a random user from Facebook API

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Reducing authentication calls on external API (Laravel 5.6)

Applying programmatically a coupon to an Order in WooCommerce3

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Send POST data via raw JSON with Postman

Laravel: Create morphs() relationship nullable

About Contact Privacy policy Terms and conditions