Skip to content
Extended functionality for Eloquent in Laravel 4 and 5
PHP JavaScript Erlang HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src/Sjdaws/Vocal Update for release Feb 16, 2015
tests Add recursive save and set relations Feb 16, 2015
.gitignore Test with 4.2 Jun 7, 2014
.scrutinizer.yml Exclude tests from scrutinizer Feb 11, 2015
.travis.yml Remove php 5.3 support Feb 13, 2015
composer.json Remove version and set range for dependencies Mar 1, 2015
licence Change namespace and prevent triple save Aug 19, 2014
phpunit.xml Test with 4.2 Jun 7, 2014
readme.md Update for release Feb 16, 2015

readme.md

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
You can’t perform that action at this time.