wemersonrv

Extending Laravel Model

Nov 18th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. class Usuario extends Eloquent{
  4.     public static $table = 'usuario';
  5.     public static $timestamps = false;
  6.  
  7.     /**
  8.      * Save the model instance to the database.
  9.      *
  10.      * @return bool
  11.      */
  12.     public function save(){
  13.        
  14.         if(isset($this->password))
  15.             $this->password = Hash::make($this->password);
  16.  
  17.         Parent::save(); // Here fails
  18.     }
  19.  
  20.     public static function validate($data){
  21.         return Validator::make($data, array(
  22.             'nome'      => 'required|min:3|max:80',
  23.             'username'  => 'required|min:3|max:20',
  24.             'password'  => 'required|min:6|max:20'
  25.         ));
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment