• 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

Utf8 encoding issue with Laravel

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

jQuery Ajax Post with data

Laravel update hasMany relationship using saveMany

Reload parent page after submit in iframe

How to get company posts from LinkedIn via API?

Laravel Command Schedule Not Working Properly

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

PHP sort array of objects by two properties

How to MODIFY a Google Docs document via API using search-and-replace?

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

Laravel Carbon get start + end of last week?

How to use $this->session->set_userdata in codeigniter

Sagepay Error The Vendor failed to provide a RedirectionURL

Woocommerce Checkout - Add conditional field required if one field is filled

About Contact Privacy policy Terms and conditions