add User Collection, adapt crud, refactor crud, add readme

This commit is contained in:
Martz
2023-02-05 20:06:44 +01:00
parent 1d1beef82a
commit c586b4b9ff
5 changed files with 105 additions and 13 deletions

View File

@@ -2,26 +2,29 @@
namespace Pb;
use UsersCollection;
class Client
{
private string $response;
private string $url;
private string $route;
public function __construct(string $url)
{
$this->response = '{}';
$this->url = $url;
$this->users = [];
}
public function collection(string $collection, int $page = 1)
public function users()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url."/api/collections/".$collection."/records?page=".$page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$collection = new Collection(curl_exec($ch));
curl_close($ch);
return new UsersCollection($this->url, 'records');
}
return json_decode($collection, JSON_FORCE_OBJECT);
public function collection($url,string $collection, int $page = 1)
{
return new Collection($this->url ,$collection);
}
}