Skip to content

Latest commit

 

History

History
executable file
·
84 lines (61 loc) · 2.53 KB

readme.md

File metadata and controls

executable file
·
84 lines (61 loc) · 2.53 KB

Vocal

Build Status License Latest Stable Version

Extended functionality for Eloquent in Laravel 4 and 5.

Some parts of Vocal are based on Ardent for Laravel 4 by Max Ehsan.

Copyright (c) 2014-2015 Scott Dawson.

Documentation

What is Vocal

Vocal makes working with nested relationships easier. This is especially helpful if you're displaying multiple models to a user at once, such as a user profile with an address book, and want them to be able to change their name and update their address in one go.

Installation

The first thing you need to do is add sjdaws/vocal as a requirement to composer.json:

{
    "require": {
        "sjdaws/vocal": "2.0.*"
    }
}

Update your packages with composer update and you're ready to go.

Getting Started

Vocal extends the Eloquent base class, so your models are still fully compatible with Eloquent. Vocal simply intercepts some methods such as validate and save before they're passed to Eloquent.

To create a new Vocal model, simply make your model class extend the Vocal base class:

use Sjdaws\Vocal\Vocal;

class User extends Vocal {}

There is no need to add any Facades or Service Providers.

Usage

Vocal provides several settings and methods:

Variable Access Modifier Type
$allowHydrationFromInput protected boolean
$hashable protected array
$languageFolder protected string
$languageKey protected string
$messages protected array
$rules public array
$validateBeforeSave protected boolean
Method Parameters
create $data, $rules, $messages
forceCreate $data
forceSave $data
forceSaveAndDelete $data
forceSaveRecursive $data
getErrors $filter
getErrorBag
hydrateModel $data
save $data, $rules, $messages
saveAndDelete $data, $rules, $messages
saveRecursive $data, $rules, $messages
timestamp $value
validate $data, $rules, $messages
validateRecursive $data, $rules, $messages