• 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

Comma separated list from array with "and" before last element

PHP drop down list using array's and foreach (else and for) code

Require a class from another class - php

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

selected value from the listbox in php

IlluminateDatabaseQueryException could not find driver [duplicate]

Laravel - Implicit route model binding with soft deleted data

GRPC installed successfully on ubuntu but php is looking for it in another folder

How to test a php login connected to a mysql db through xampp?

Create a zip file and download it

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Laravel Livewire: jQuery not working in child component loaded via @if statement

MOODLE: What does it mean to aggregate h5p assets?

Can't find vendor/autoload.php for Ratchet

Jquery DataTables: Data not displaying in table via Ajax

About Contact Privacy policy Terms and conditions