• 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

Sum array values of a column within each column of an array with 3 levels

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

auth pages not getting css in laravel

How can I make Laravel return a custom error for a JSON REST API

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

PHP Include for HTML?

Add bold text and line break into Laravel Notification Email

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Laravel Blade checkbox not checked

Laravel MSSQL Server Connection not working

How to create a video stream from a single dynamic image in PHP

WHM Enabling mod_rewrite

Group rows by column and sum another column within groups [duplicate]

How Can I Do LIMIT 1, 2 In WP_Query

About Contact Privacy policy Terms and conditions