awareness / aware by colbyr
forked from colbyr/aware

Model validation for L4 Eloquent
360
27
4
Package Data
Maintainer Username: colbyr
Maintainer Contact: crabideau5691@gmail.com (Colby Rabideau)
Package Create Date: 2013-02-17
Package Last Update: 2013-06-03
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:12:10
Package Statistics
Total Downloads: 360
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 27
Total Watchers: 4
Total Forks: 3
Total Open Issues: 1

Aware

Self validating models for Eloquent in L4

Build Status

Installation

Composer

{ // composer.json
  ...
  "require": {
    "laravel/framework": "4.0.*",
    "awareness/aware": "dev-master"
  },
  ...
}

Usage

Create a model with validation rules:

<?php

use Awareness\Aware\Model;

class User extends Model {

  public static $rules = array(
    'name' => 'required'
  );

}

Try to save it:

$user = new User();
$user->save(); // returns false

$user->name = 'Colby';
$user->save(); // saves then returns true!

Save without validating:

$user = new User();
$user->force()->save();