Package Data | |
---|---|
Maintainer Username: | teepluss |
Maintainer Contact: | admin@laravel.in.th (Teepluss) |
Package Create Date: | 2013-08-06 |
Package Last Update: | 2014-08-25 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-11 15:01:09 |
Package Statistics | |
---|---|
Total Downloads: | 189 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This is my internal project, not yet complete.
To get the lastest version of Theme simply require it in your composer.json
file.
"teepluss/harvey": "dev-master"
You'll then need to run composer install
to download it and have the autoloader updated.
class Blog extends \Teepluss\Harvey\Harvey {
/**
* Define rules.
*
* @type array
*/
public static $rules = array(
'description' => 'min:10|max:500',
'onCreate' => array(
'title' => 'required',
'url' => 'active_url'
),
'onUpdate' => array(
'title' => 'required'
)
);
/**
* Custom validation messages.
*
* @type array
*/
public static $messages = array(
'title.required' => 'Please fill title before submitting.'
);
/**
* Custom validation labels.
* @type array
*/
public static $lables = array(
'title' => 'Title'
);
/**
* Construct.
* @param array $attributes
* @return void
*/
public function __construct(array $attributes = array())
{
parent::__construct($attributes);
// Custom label.
$this->setLabelNames(array(
'title' => trans('labels.product'),
));
}
/**
* Event before validate.
*
* @return voide
*/
protected function beforeValidate()
{
$validator->sometimes('description', 'numeric', function($input)
{
return $input->title == 'tee';
});
}
}
$blog = new Blog;
$blog->title = 'New blog';
$blog->description = 'This is my first entry';
$blog->url = 'http://www.domain.com';
// Addition rule for another input.
$blog->addValidate(
array('other' => Input::get('other')),
array('other' => 'required|email'),
array('other.required' => 'sss')
);
if ( ! $blog->save())
{
$errors = $blog->errors();
return Redirect::back()->withErrors($errors)->withInput();
}
array(3) [
'description' => array(2) [
string (6) "min:10"
string (7) "max:500"
]
'title' => array(1) [
string (8) "required"
]
'url' => array(1) [
string (10) "active_url"
]
]
$blog = Blog::find(1);
$blog->title = 'New blog';
$blog->description = 'This is my first entry';
$blog->url = 'http://www.domain.com';
$blog->save();
if ( ! $blog->save())
{
$errors = $blog->errors();
return Redirect::back()->withErrors($errors)->withInput();
}
array(2) [
'description' => array(2) [
string (6) "min:10"
string (7) "max:500"
]
'title' => array(1) [
string (8) "required"
]
]
If you have some problem, Contact teepluss@gmail.com