PHP Services

Additional functionality

Service is a class that provides additional functionality. Services can be loaded using get() method.

Example code

$userName = $this->get('user')->getName();

Use examples

Getting information from other tables

Get all pages from Bill -table where 'Status=Unpaid' and show total sum:

$unpaidTotal = $this->get('pages', 'bill')->addWhere('status','Unpaid')->calculate('sum');

Sending email

Get mail -resource and send an email

$this->get('mail', Array(
  'from' => $Order->employee->email,
  'to' => $Order->customer->email,
  'subject' => 'Offer',
  'body' => Have you got our offer?'
))->send();