dhandarbeit-tk/laravel-boilerplate-platform

The Laravel Framework.

1.0 2018-12-10 13:47 UTC

This package is not auto-updated.

Last update: 2024-04-10 22:36:54 UTC


README

Provides useful helper functions and class structure for core functionality of laravel/laravel.

Built to be customizable.

Installation

Create project
composer create-project dhandarbeit-tk/laravel-boilerplate-platform

Preinstalled packages

New Defaults

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

Other defaults:

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

Directories

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

Helper Functions

(app/Support/helpers.php)

  • array_ensured($array, $data)
    • return $array, containing all keys of data, and value if $array doesnt have the key
  • user()
    • shorthand for auth()->user()
  • decodeHashid($connection, $encoded, $default)
    • returns decoded hashid of $encoded for $connection; if not possible, return $default
  • encodeHashid($connection, $decoded)
    • returns encoded hashid of $decoded for $connection
  • isCurrentRelease()
    • determines if running release is most recent release (useful for deployment related things)

Customizable classes and methods

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

    • is($model = null) (overwrite)
      • allows argument to be null (returns false)
    • isClass($class)
  • App\Eloquent\Models\Traits\HasTimestamps

    • updateTimestamps() (overwrite)
      • only sets updated_at when updating, not when creating
  • App\Eloquent\Models\Pivots\Pivot (trait: IsPivot)

  • App\Support\Collection (trait: CollectionTrait)

    • implode($value, $glue = null, $skipNull = false) (overwrite)
      • allows to skip null
  • App\Eloquent\Collections\Collection (trait: CollectionTrait)

    • without($model = null)
      • return a new Collection without $model
    • eachDelete()
      • runs delete() on each model
    • eachAppends($attributes)
      • runs appends($attributes) on each model

Stubs

  • artisan make:model
    • (app/Console/stubs/model.stub)
    • prefills table name
    • has predefined areas for relationships