• 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 5.1 Unknown database type enum requested

php echo xml documents with header

Select option from dropdown menu with PHP and mySql

Must be of the type array, null given,

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

Laravel post contact form giving me error 419

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

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

XML to CSV with PHP converter [problem with images grabing]

Laravel MSSQL Server Connection not working

laravel and phpunit: could not find driver (SQL: PRAGMA foreign_keys = ON;)

Insert And Retrieve Data in MySQL with $.post Noob Question

Guzzle Not Sending Grant Type to Laravel Passport

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

About Contact Privacy policy Terms and conditions