PHPackages                             coyote6/laravel-base - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. coyote6/laravel-base

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

coyote6/laravel-base
====================

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.

v0.2.7(9mo ago)0842MITPHP

Since Aug 16Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/Coyote6/laravel-base)[ Packagist](https://packagist.org/packages/coyote6/laravel-base)[ Docs](https://coyote6.com)[ RSS](/packages/coyote6-laravel-base/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (11)Used By (2)

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
------

[](#to-use)

1. Select which traits you would like to implement.
2. Add that trait(s) to the model.

### Available Traits

[](#available-traits)

#### Boot Method

[](#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

[](#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

[](#select-dropdownradio-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

[](#query-helpers)

GetBySlug - Selects a model by a unique `slug` property.

Examples
--------

[](#examples)

### Uuid Example

[](#uuid-example)

App\\Models\\Example.php

```
