• 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 xmlHttpRequest AJAX POST TokenMismatchException

How to check user Permissions using Custom Middleware in Laravel

add " ? " in url via htaccess RewriteRule

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Laravel relationship belongsToMany with composite primary keys

PHP/HTML: Creating A SubMenu

MySQL default time format UTC or GMT?

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

laravel 5.6 bulk inserting json data

Laravel Pagination links() not working

Problem with fetching data from database in Laravel

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

laravel MVC execution flow

Laravel/docker-compose/redis - Class 'Redis' not found

file_put_content...fail to open stream:Permission denied in Laravel 5

About Contact Privacy policy Terms and conditions