Skip to content

Set a datetime attribute separately using a date and a time. This is especially helpful for input[type=date] and input[type=time].

License

Notifications You must be signed in to change notification settings

limenet/laravel-datetime-attributes

Repository files navigation

Laravel Datetime Attributes

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Set a datetime attribute separately using a date and a time. This is especially helpful for input[type=date] and input[type=time]

Usage

<?php

use Illuminate\Database\Eloquent\Model as Base;
use Limenet\LaravelDatetimeAttributes\DateTimeTrait;

class Model extends Base
{
    use DateTimeTrait;

    public function getStartDateAttribute()
    {
        return $this->dtGetDate('start');
    }

    public function getStartTimeAttribute()
    {
        return $this->dtGetTime('start');
    }

    public function setStartDateAttribute($value)
    {
        $this->dtSetDate('start', $value);
    }

    public function setStartTimeAttribute($value)
    {
        $this->dtSetTime('start', $value);
    }
}

About

Set a datetime attribute separately using a date and a time. This is especially helpful for input[type=date] and input[type=time].

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages