Package Data | |
---|---|
Maintainer Username: | Sukohi |
Maintainer Contact: | sukohi.capilano@gmail.com (Sukohi) |
Package Create Date: | 2017-07-31 |
Package Last Update: | 2017-08-16 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-23 03:03:51 |
Package Statistics | |
---|---|
Total Downloads: | 22 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A Laravel package for custom casts.
Execute composer command.
composer require sukohi/custom-cast:1.*
Simple Way
In your model, set CustomCastTrait
and add $casts
as usual.
<?php
namespace App;
use Sukohi\CustomCast\CustomCastTrait;
class User {
use CustomCastTrait;
protected $casts = [
'column' => 'CUSTOM-CAST-NAME'
];
Now you can use custom casts.
You need to set alpha_boolean
.
This might be useful for JavaScript Object key.
protected $casts = [
'activated' => 'alpha_boolean'
];
You need to set alpha_ternary
.
protected $casts = [
'status_type_id' => 'alpha_ternary'
];
hh::ii:ss => hh:ii
protected $casts = [ 'meeting_time' => 'short_time' ];
// i.g) 01:02:03 => 01:02
This package is licensed under the MIT License.
Copyright 2017 Sukohi Kuhoh