• 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 Can I Do LIMIT 1, 2 In WP_Query

How to get monthly wise data in laravel

Webscraping Symfony/Panther: Can't get HTML

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

How to auto populate preferredCountries from intl-tel-input with db output

Check if my GET request has Header: Token

how to loop through json response data using ajax jquery?

How can i update or reset my password without entering email field in laravel-8?

How to give apache permission to write to home directory?

PHP file_get_contents function

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

Magento 2 - Controller returning blank page

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

Ajax GET request fails in laravel 8

About Contact Privacy policy Terms and conditions