parent
							
								
									72ddd75023
								
							
						
					
					
						commit
						f1529b3b8e
					
				| @ -0,0 +1,34 @@ | |||||||
|  | <?php | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | namespace App\Models; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | use Illuminate\Database\Eloquent\Model; | ||||||
|  | 
 | ||||||
|  | class BaseModel extends Model | ||||||
|  | { | ||||||
|  |     public function getAttribute($key) | ||||||
|  |     { | ||||||
|  |         if (! $key) { | ||||||
|  |             throw new \LogicException("No attribute ".var_export($key, true)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return parent::getAttribute($key); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Get a relationship. | ||||||
|  |      * | ||||||
|  |      * @param  string  $key | ||||||
|  |      * @return mixed | ||||||
|  |      */ | ||||||
|  |     public function getRelationValue($key) | ||||||
|  |     { | ||||||
|  |         if (!method_exists($this, $key)) { | ||||||
|  |             throw new \LogicException("No attribute or relation ".var_export($key, true)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return parent::getRelationValue($key); | ||||||
|  |     } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue