# Resource

# Definition

Payment, Customer and Log classes have an instance of resource. That means, you can use the resource methods in those classes.

# Methods

# find

  • params: ($value)
  • returns: instance|bool

You can find an instance of an object with a string of uuid or with a pay_id. If the resource does not found anything, returns false

use Beebmx\KirbyPay\Customer;

//Should be a valid uuid
Customer::find('4f139ef0-484a-4749-a51f-5ffe339dd1c1');

//Should be a valid pay_id
Customer::find(1);

# first

  • params: none
  • returns: instance|bool

Returns an instance of the first element created. If the resource does not found anything, returns false

use Beebmx\KirbyPay\Customer;

Customer::first();

TIP

The order to sort the resources is chronologically inverse, that means, it's the last created.

# last

  • params: none
  • returns: instance|bool

Returns an instance of the last element created. If the resource does not found anything, returns false

use Beebmx\KirbyPay\Customer;

Customer::last();

TIP

The order to sort the resources is chronologically inverse, that means, it's the first created.

# write

  • params: (array $attributes, int $pay_id = null, string $uuid = null)
  • returns: instance

Returns an instance of the element created. If you don't send a $pay_id and a $uuid it creates a new resource, otherwise it will rewrite the existing one.

use Beebmx\KirbyPay\Customer;

Customer::write([
    'name' => 'John Doe',
    'email' => 'email@example.com'
]);

# read

  • params: (string $file)
  • returns: Illuminate\Support\Collection

Returns an instance Illuminate\Support\Collection of the element.

use Beebmx\KirbyPay\Customer;

Customer::read('1-4f139ef0-484a-4749-a51f-5ffe339dd1c1.json');

# destroy

  • params: (int $pay_id, string $uuid)
  • returns: bool

Returns a boolean if the resource was successfully deleted.

use Beebmx\KirbyPay\Customer;

Customer::destroy(1, '4f139ef0-484a-4749-a51f-5ffe339dd1c1.json');

# get

  • params: none
  • returns: array

Returns an array with all the resources.

use Beebmx\KirbyPay\Customer;

Customer::get();

# take

  • params: (int $number = 10)
  • returns: Resource

Take only the $number of elements in the resource.

Returns an instance of the resource.

use Beebmx\KirbyPay\Customer;

Customer::take()->get();

# skip

  • params: (int $number = 10)
  • returns: Resource

Skip the $number of elements in the resource.

Returns an instance of the resource.

use Beebmx\KirbyPay\Customer;

Customer::skip()->get();
  • params: (string $query, array $params)
  • returns: Resource

Search elements in the resource by one or more parameters.

Returns an instance of the resource.

If you search with only one parameter.

use Beebmx\KirbyPay\Customer;

Customer::search(1, 'pay_id')->get();
Customer::search('4f139ef0-484a-4749-a51f-5ffe339dd1c1', 'uuid')->get();
Customer::search('jane', 'email')->get();

If you search with more than one parameter.

use Beebmx\KirbyPay\Customer;

Customer::search('26', 'pay_id|uuid')->get();

# page

  • params: (int $page = 1, int $perPage = 10)
  • returns: Resource

Paginate elements in the resource.

Returns an instance of the resource.

use Beebmx\KirbyPay\Customer;

Customer::page()->get();

# diffForHumans

  • params: none
  • returns: Resource

Transform all the dates (created_at and updated_at) to a human format.

Returns an instance of the resource.

use Beebmx\KirbyPay\Customer;

Customer::diffForHumans()->get();

# withPayIdFormat

  • params: none
  • returns: Resource

Transform all the pay_id to fill with zeros defined in the pay_id_length option.

Returns an instance of the resource.

use Beebmx\KirbyPay\Payment;

Payment::withPayIdFormat()->get();

# withoutMoneyCast

  • params: none
  • returns: Resource

This method disabled the amount casting in the resources.

Returns an instance of the resource.

use Beebmx\KirbyPay\Payment;

Payment::withoutMoneyCast()->get();

# setSort

  • params: (string $sort = 'desc')
  • returns: Resource

Set the sort direction of the resource's elements.

Returns an instance of the resource.

use Beebmx\KirbyPay\Customer;

Customer::setSort('asc')->get();

# count

  • params: none
  • returns: int

Returns the number of the elements in the resource.

use Beebmx\KirbyPay\Customer;

Customer::count();

# isEmpty

  • params: none
  • returns: bool

Returns a boolean if the resource is empty.

use Beebmx\KirbyPay\Customer;

Customer::isEmpty();

# isNotEmpty

  • params: none
  • returns: bool

Returns a boolean if the resource is not empty.

use Beebmx\KirbyPay\Customer;

Customer::isNotEmpty();

# getPath

  • params: none
  • returns: string

Returns a string with the name path of the resource.

use Beebmx\KirbyPay\Customer;

Customer::getPath();