class Category extends Model { 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' => '*****@*****.**',
/** * Set the guzzle instance. */ private function mockGuzzle($callback) { $guzzle = Mockery::mock(GuzzleHttp::class); $callback($guzzle); Model::setHttpClient($guzzle); }