• 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

str_word_count() function doesn't display Arabic language properly

How can I get new CSRF token in LARAVEL by using ajax

Laravel 5.5 change unauthenticated login redirect url

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

Google Calendar API batch request PHP

Fetch files from next cloud storage and display in Laravel website

"There is no active transaction" when refreshing database in Laravel 8.0 test

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

How To Access A Column In M-M Relationship Table In Laravel

Extract house numbers from address string

Performance of foreach, array_map with lambda and array_map with static function

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Timber: Single post pagination does not work (wp_link_pages)

Appending data to an anchor tag

Laravel Get Days In Month From Month Number?

About Contact Privacy policy Terms and conditions