mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
start with Collection Class
This commit is contained in:
@@ -11,6 +11,7 @@ class Client
|
|||||||
{
|
{
|
||||||
$this->response = '{}';
|
$this->response = '{}';
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
$this->users = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collection(string $collection, int $page = 1)
|
public function collection(string $collection, int $page = 1)
|
||||||
@@ -18,10 +19,9 @@ class Client
|
|||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $this->url."/api/collections/".$collection."/records?page=".$page);
|
curl_setopt($ch, CURLOPT_URL, $this->url."/api/collections/".$collection."/records?page=".$page);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$this->response = curl_exec($ch);
|
$collection = new Collection(curl_exec($ch));
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
return json_decode($this->response, JSON_FORCE_OBJECT);
|
return json_decode($collection, JSON_FORCE_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/Collection.php
Normal file
17
src/Collection.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pb;
|
||||||
|
|
||||||
|
class Collection
|
||||||
|
{
|
||||||
|
private $json;
|
||||||
|
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->json = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authWithPassword(){
|
||||||
|
var_dump($this->json);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user