joaorbrandao/laravel-intervals 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joaorbrandao/laravel-intervals

Composer 安装命令:

composer require joaorbrandao/laravel-intervals

包简介

This package creates a simple way of adding time intervals to your projects.

README 文档

README

This package creates a simple way of adding time intervals to your projects.

Latest Stable Version Total Downloads License

Installing

composer require joaorbrandao/laravel-intervals

Publish the package into your application.

php artisan vendor:publish --provider=Joaorbrandao\LaravelIntervals\LaravelIntervalsServiceProvider

A folder containing some filters will be published in "app/LaravelIntervals".
Feel free to modify/delete them if you want!

Usage

Create a new Interval

This command will create a new interval in "app/LaravelIntervals".

php artisan make:interval FirstDayOfLastWeek

Setup the Interval

Each time interval has 5 properties: start, end, enabled, id and name.

Property Description
start Represents the start time of the interval.
end Represents the end time of the interval.
enabled Enables/disables the usage of the interval.
id Identifies the interval as unique.
name The interval's name for translation purposes.

After running the command to create the interval, you must change the start and end to match with the interval name.

<?php

namespace App\LaravelIntervals;


use Joaorbrandao\LaravelIntervals\Contracts\Interval;

final class FirstDayOfLastWeek implements Interval
{
    public function resolve()
    {
        return [
            'start' => now()->subWeek()->startOfWeek()->startOfday(),
            'end' => now()->subWeek()->startOfWeek()->endOfDay(),
            'enabled' => true,
            'id' => 'firstDayOfLastWeek',
            'name' => 'first_day_of_last_week',
        ];
    }
}

Make use of it!

One of the ways of using this is with the Facade. The result of the facade is the time interval set defined in the configuration file with the start and end properties being Carbon instances.

LaravelIntervals::last365Days();

// Return
Joaorbrandao\LaravelIntervals\Interval^ {#382
    +end: Illuminate\Support\Carbon @1571693543^ {#767
        date: 2019-10-21 21:32:23.050513 UTC (+00:00)
    }
    +id: "last365Days"
    +name: "last_65_days"
    +start: Illuminate\Support\Carbon @1540157543^ {#768
        date: 2018-10-21 21:32:23.050440 UTC (+00:00)
    } 
}

License

laravel-intervals is an open-source laravel package licensed under the MIT license.

统计信息

  • 总下载量: 355
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固