//ads:
?>
Passing a boolean value from checkbox in Laravel form
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');