• 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

How to get AJAX to post on second page?

Laravel Delete and Update

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

CodeIgniter 3 is generating a session file on each request, why?

How to write PHP in XSLT

php code to send checkbox form results to email

how to hide previous markers when new markers added in google map javascript api

Sliders in Laravel

PHP -> Next nearest date defined by array of days in week

ConstraintViolationListInterface to Exception in Symfony

laravel 5.6 bulk inserting json data

How do I refresh a DIV content?

Show date difference as "20" instead of "20 years ago"

PHP header location absolute URL

Creating Combinations of Elements

About Contact Privacy policy Terms and conditions