コード例 #1
0
ファイル: Client.php プロジェクト: robgridley/pace-api
 /**
  * Dynamically retrieve the specified model.
  *
  * @param string $name
  * @return Model
  */
 public function __get($name)
 {
     return $this->model(Type::modelify($name));
 }
コード例 #2
0
ファイル: TypeTest.php プロジェクト: robgridley/pace-api
 public function testModelifyMethod()
 {
     $this->assertEquals('GLBatch', Type::modelify('glBatch'));
     $this->assertEquals('SalesPerson', Type::modelify('salesPerson'));
 }
コード例 #3
0
ファイル: Model.php プロジェクト: robgridley/pace-api
 /**
  * Auto-magically fetch relationships.
  *
  * @param string $method
  * @return Builder|Model|null
  */
 protected function getRelatedFromMethod($method)
 {
     // If the called method name exists as a property on the model,
     // assume it is the camel-cased related type and the property
     // contains the foreign key for a "belongs to" relationship.
     if ($this->hasProperty($method)) {
         if (!$this->relationLoaded($method)) {
             $relatedType = Type::modelify($method);
             $this->relations[$method] = $this->belongsTo($relatedType, $method);
         }
         return $this->relations[$method];
     }
     // Otherwise, the called method name should be a pluralized,
     // camel-cased related type for a "has many" relationship.
     $relatedType = Type::modelify(Type::singularize($method));
     $foreignKey = Type::camelize($this->type);
     return $this->hasMany($relatedType, $foreignKey);
 }