Download the PHP package coyote6/laravel-base without Composer
On this page you can find all versions of the php package coyote6/laravel-base. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coyote6/laravel-base
More information about coyote6/laravel-base
Files in coyote6/laravel-base
Package laravel-base
Short Description Provides common base classes used for some of Coyote6 GraphX's developed projects. Provides UUID trait for models using it as a primary key. Provides trait methods to return models as options.
License MIT
Homepage https://coyote6.com
Informations about the package laravel-base
Laravel Base
This is just a collection of commonly used traits that are used throughout my sites and packages, such as UUIDs and autofilling author_id fields on models.
To use
- Select which traits you would like to implement.
- Add that trait(s) to the model.
Available Traits
Boot Method
BootTraits - Used to call the boot methods on creating, created, updating, updated, deleting, and deleted methods. Calls the parent method prior to implementing the other methods. Also adds static::getUser(), static::getUserId() methods to the find the current user in other traits.
Creation Helpers That Require The Boot Method
HasAuthor - Autofills a author_id
property on the model using the current user's id
.
HasClient - Autofills a client_id
property on the model using the current user's client_id
if the user has one.
HasMachineName - Autofills a machine_name
property on the model using the name
property, removing spaces and all punctuations.
HasUuid - Autofills the id
property on the model with a uuid.
Select Dropdown/Radio Button Helpers
GetAsOptions - Uses the id
and name
model properties to create an array of options for select dropdowns and radio buttons.
GetAsOptionsAbbr - Uses the abbr
and name
model properties to create an array of options for select dropdowns and radio buttons. (Same as GetAsOptions, but uses an abbreviation field instead of the name. Mainly used for states and countries.)
Query Helpers
GetBySlug - Selects a model by a unique slug
property.
Examples
Uuid Example
App\Models\Example.php
This example just auto adds a uuid as the id
if not filled in on creation.
All Boot Traits Example
App\Models\Example.php
This example auto adds a uuid as the id
, the user\'s id and client id as author_id
and client_id
respectfully, and a machine name_based
on the name
if not filled in on creation.
Get As Options Example
App\Models\Example.php
App\Http\Controllers\ExampleController.php
Get As Options Abbreviation Example
App\Models\Example.php
App\Http\Controllers\ExampleController.php
Get By Slug Example
App\Models\Example.php
App\Http\Controllers\ExampleController.php