Created
October 16, 2014 15:23
-
-
Save DB-009/2f494b93e852b7f24ef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ArtObj extends Eloquent { | |
protected $table = 'art_objects'; | |
public $primaryKey = 'object_id'; | |
public $timestamps = false; | |
private $rules = array('object_title' => 'required|' , | |
'desc' => 'required', | |
'catalog' => 'required', | |
'collection' => 'required', | |
'date_made'=> 'required', | |
'author' => 'required', | |
'place_made' => 'required', | |
'datasource' => 'required', | |
'measurements' => 'required' | |
); | |
private $messages = array( | |
'object_title.required' => 'The Titile field is required.', | |
'desc.required' => 'The Description field is required.', | |
'catalog.required' => 'The Catalog field is required.', | |
'collection.required' => 'The Collections field is required.', | |
'date_made.required' => 'The Date Made field is required.', | |
'author.required' => 'The Author field is required.', | |
'place_made.required' => 'The Place Made field is required.', | |
'datasource.required' => 'The Datasource field is required.', | |
'measurements.required' => 'The measurements field is required.' | |
); | |
private $errors; | |
public function validate($data) | |
{ | |
// make a new validator object | |
$v = Validator::make($data, $this->rules , $this->messages); | |
// check for failure | |
if ($v->fails()) | |
{ | |
// set errors and return false | |
$this->errors = $v->errors(); | |
return false; | |
} | |
// validation pass | |
return true; | |
} | |
public function errors() | |
{ | |
return $this->errors; | |
} | |
public function Objgroup() | |
{ | |
return $this->belongsTo('Obj_group', 'obj_group_id', 'tour_object_id'); | |
} | |
public function ObjCollection() | |
{ | |
return $this->belongsTo('ObjCollection', 'obj_group_id'); | |
} | |
public function medias() | |
{ | |
return $this->hasMany('Media','parent_id','object_id'); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment