dhandarbeit-tk/laravel-boilerplate-platform

Laravel 框架。

1.0 2018-12-10 13:47 UTC

This package is not auto-updated.

Last update: 2024-09-26 00:37:09 UTC


README

laravel/laravel 的核心功能提供有用的辅助函数和类结构。

构建为可定制。

安装

创建项目
composer create-project dhandarbeit-tk/laravel-boilerplate-platform

预安装的包

新默认值

  • LOG_CHANNEL=daily
  • database.migrations=laravel_migrations
  • queue.database.table=laravel_jobs
  • queue.failed.table=laravel_failed_jobs

其他默认值

  • app.locale=de
  • app.timezone=Europe/Berlin

目录

  • app/Support
  • app/Eloquent/Models
  • app/Eloquent/Collections

辅助函数

(app/Support/helpers.php)

  • array_ensured($array, $data)
    • 返回包含数据所有键的 $array,如果 $array 没有该键,则包含值
  • user()
    • auth()->user() 的简写
  • decodeHashid($connection, $encoded, $default)
    • 返回 $encoded 的解码 hashid;如果不可能,则返回 $default
  • encodeHashid($connection, $decoded)
    • 返回 $decoded 的编码 hashid
  • isCurrentRelease()
    • 确定正在运行的版本是否为最新版本(用于与部署相关的事项)

可定制的类和方法

  • App\Eloquent\Models\Model (trait: IsModel)

    • is($model = null) (覆盖)
      • 允许参数为 null(返回 false)
    • isClass($class)
  • App\Eloquent\Models\Traits\HasTimestamps

    • updateTimestamps() (覆盖)
      • 仅设置 updated_at 当更新时,不设置创建时
  • App\Eloquent\Models\Pivots\Pivot (trait: IsPivot)

  • App\Support\Collection (trait: CollectionTrait)

    • implode($value, $glue = null, $skipNull = false) (覆盖)
      • 允许跳过 null
  • App\Eloquent\Collections\Collection (trait: CollectionTrait)

    • without($model = null)
      • 返回一个新的不包含 $model 的 Collection
    • eachDelete()
      • 对每个模型运行 delete()
    • eachAppends($attributes)
      • 对每个模型运行 appends($attributes)

存根

  • artisan make:model
    • (app/Console/stubs/model.stub)
    • 预填充表名
    • 有预定义的关系区域