• 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 to create a individual template for page or post in custom plugin?

PHP mail sending empty mails

Add Class in html Dynamically in PHP

In PHP, which is faster: preg_split or explode?

Use Python plotly chart in PHP

Create a new line whenever an array value reaches more than 10 characters

Override default Auth routes in Laravel 7

Navigation idle on content download

Normalize DateInterval in PHP

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

yii2 and mssql insert varbinary into model

Laravel Command Schedule Not Working Properly

how to search for a file with php

How can i hide dt if dd got empty value

Create tags in laravel post publishing

About Contact Privacy policy Terms and conditions