示例#1
0
文件: Model.php 项目: thirteen/pull
 /**
  * Return all the rows.
  *
  * @return \Illuminate\Support\Collection
  */
 public function get()
 {
     $url = $this->table;
     if ($this->parent) {
         $url = $this->parent->getTable() . '/' . $this->parent->id . '/' . $this->table;
     }
     $response = $this->request('get', $url, $this->parameters);
     return collect($response)->map(function ($row) {
         return $this->newInstance($row, $exists = true);
     });
 }
示例#2
0
文件: test.php 项目: thirteen/pull
    public function posts()
    {
        return $this->hasResource(Post::class);
    }
}
class Post extends Model
{
    public function category()
    {
        return $this->hasResource(Category::class);
    }
}
$client = new Client(['base_uri' => 'http://headless.app/api/']);
Model::setHttpClient($client);
$token = Model::authenticate(['email' => '*****@*****.**', 'password' => 'password']);
Model::setDefault('access_token', $token);
//
// $response = $client->get('posts', [
//     'query' => [
//         'limit' => 1
//     ]
// ]);
// echo $response->getBody();
// exit;
//
// $session = new Session;
//
// $session->login([
//     'email'    => '*****@*****.**',
//     'password' => 'password',
// ]);
示例#3
0
 /**
  * Set the guzzle instance.
  */
 private function mockGuzzle($callback)
 {
     $guzzle = Mockery::mock(GuzzleHttp::class);
     $callback($guzzle);
     Model::setHttpClient($guzzle);
 }