Package Data | |
---|---|
Maintainer Username: | sarahman |
Maintainer Contact: | aabid048@gmail.com (Syed Abidur Rahman) |
Package Create Date: | 2019-03-30 |
Package Last Update: | 2023-10-24 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-17 03:10:23 |
Package Statistics | |
---|---|
Total Downloads: | 202 |
Monthly Downloads: | 1 |
Daily Downloads: | 1 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This library can be used in the scenarios when you want to understand the db boolean field value as not only its status but also the time when it becomes true.
<?php
namespace App;
use Sarahman\Database\Support\BooleanTimestampFieldManipulator;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use BooleanTimestampFieldManipulator;
protected $fillable = ['title', 'description', 'is_active'];
protected static $boolTimestampFields = ['is_active'];
}
This trait is installed via Composer. To install, simply add to your composer.json
file:
composer require sarahman/laravel-timestamp-boolean-fields:1.1.*
After installing, you would just use it in your eloquent/model class and define the timestamp-based boolean fields in the $boolTimestampFields
property as well as in $fillable
property.
Note: The timestamp-based field names must be prefixed by is_
; and the field names without its is_
prefix will be appended in the model attributes with time_being_
prefix; i.e. is_active
field name will appended in the model attributes as time_being_active
name. The is_active
field value will be boolean and time_being_active
field value will the timestamp value.
If you are having general issues with this package, feel free to contact me through Gmail.
If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.
If you're using this package, I'd love to hear your thoughts. Thanks! Please feel free to contribute in this library and send us pull requests.
The MIT License (MIT). Please see License File for more information.