コード例 #1
0
ファイル: HasOne.php プロジェクト: sahanh/resto
 public function buildQueryPath()
 {
     //ie:- users/1
     $caller_path = $this->getCallingModel()->getEntityPath();
     //ie:- posts
     $relatives_path = Str::collectionPath($this->getRelatingModel());
     //since it's one to one, relation path should be singular
     $relatives_path = Str::singular($relatives_path);
     //ie:- users/1/post
     return implode('/', array($caller_path, $relatives_path));
 }
コード例 #2
0
ファイル: Model.php プロジェクト: sahanh/resto
 /**
  * Get Collection path for same type of entities. Typically generated by pluralizing class name.
  * Used when creating new objects. ie:- POST /users
  */
 public function getCollectionPath()
 {
     if (!$this->collection_path) {
         return Str::collectionPath(get_called_class());
     } else {
         return $this->collection_path;
     }
 }
コード例 #3
0
ファイル: StrTest.php プロジェクト: sahanh/resto
 public function testCollectionPath()
 {
     $this->assertEquals('users', Str::collectionPath('Foo\\User'));
     $this->assertEquals('users', Str::collectionPath('Foo\\Bar\\User'));
 }