Advertisement
Guest User

Untitled

a guest
Nov 12th, 2014
1,221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. class BaseModel extends Eloquent {
  2.  
  3.     protected $year = null;
  4.  
  5.     public function setYear($year){
  6.         $this->year = $year;
  7.         if($year != null){
  8.             $this->table = 'gamedata_'.$year.'_'.$this->getTable();
  9.         }
  10.     }
  11.  
  12.     public static function year($year){
  13.         $instance = new static;
  14.         $instance->setYear($year);
  15.         return $instance->newQuery();
  16.     }
  17.  
  18.     public function newInstance($attributes = array(), $exists = false)
  19.     {
  20.         $model = parent::newInstance($attributes, $exists);
  21.         $model->setYear($this->year);
  22.         return $model;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement