Documentation

AgencyRepository extends Repository

Table of Contents

PAGINATION_LIMIT  = 15
RESPONSE_STATUS_ERROR  = 'error'
RESPONSE_STATUS_FAIL  = 'fail'
RESPONSE_STATUS_SUCCESS  = 'success'
$model  : mixed
Model var
$repo  : mixed
Repo var
__construct()  : mixed
all()  : array<string|int, mixed>
Get all instances of model
cleanNullValues()  : null
Change null values and put string("")
create()  : object
Create a new record in the database
delete()  : bool
It soft-deletes a record from the database
ensureHttp400Code()  : string
Return a extension from mimetype
firstOrCreate()  : object
Retrieves first element of the database. If it doesn't exists, it creates it before returning it.
firstOrNew()  : object
Retrieves first element of the database. If it doesn't exists, it instanciates it before returning it.
forceDelete()  : bool
It definitely removes a record from the database
getAccessToken()  : bool
getAgency()  : string
getConcatString()  : string
Concatenate string to make it compatible with SQLite
getErrorResponse()  : array<string|int, mixed>
Return all an array of errors like validation in one format
getFailResponse()  : array<string|int, mixed>
Return all an array of errors like validation in one format
getModel()  : Model
Get the associated model
getPaymentMethods()  : string
getSuccessResponse()  : array<string|int, mixed>
Return all an array of errors like validation in one format
licenses()  : string
licenses_store()  : string
microsecondsToSeconds()  : array<string|int, mixed>
Return all an array of errors like validation in one format
mime2ext()  : string
Return a extension from mimetype
modules()  : object
orderQuery()  : null
Destroy record from the database
paginate()  : Model
renewAccessToken()  : bool
sendMail()  : bool
Send an email
setModel()  : mixed
Set the associated model
show()  : object
Show the record with the given id
showFromAccessToken()  : object
showWith()  : Model
Eager load database relationships
store()  : array<string|int, mixed>
update()  : object
Updates a record in the database
updatePaymentMethods()  : bool
updatePermissions()  : object
users()  : string
users_delete()  : string
users_link()  : string
users_show()  : object
users_store()  : array<string|int, mixed>
users_update()  : object

Constants

PAGINATION_LIMIT

public mixed PAGINATION_LIMIT = 15

RESPONSE_STATUS_ERROR

public mixed RESPONSE_STATUS_ERROR = 'error'

RESPONSE_STATUS_FAIL

public mixed RESPONSE_STATUS_FAIL = 'fail'

RESPONSE_STATUS_SUCCESS

public mixed RESPONSE_STATUS_SUCCESS = 'success'

Properties

Methods

__construct()

public __construct(Agency $model) : mixed
Parameters
$model : Agency
  • Instance of Agency Model.
Tags
desc

Creates an instance of the Class

Return values
mixed

all()

Get all instances of model

public all() : array<string|int, mixed>
Tags
desc

Get all instances of model

Return values
array<string|int, mixed>

cleanNullValues()

Change null values and put string("")

public cleanNullValues(array<string|int, mixed> &$data[, array<string|int, mixed> $exceptions = [] ]) : null
Parameters
$data : array<string|int, mixed>
  • Array with parameters
$exceptions : array<string|int, mixed> = []
  • Array with exceptions keys
Return values
null

create()

Create a new record in the database

public create(array<string|int, mixed> $data) : object
Parameters
$data : array<string|int, mixed>
  • Data of the object that we want to create.
Tags
throws
Exception
Return values
object

delete()

It soft-deletes a record from the database

public delete(array<string|int, mixed> $data, int $id) : bool
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to delete.
$id : int
  • Id of the object that we want to remove.
Tags
desc

Delete record from the database

Return values
bool
  • Success or fail

ensureHttp400Code()

Return a extension from mimetype

public ensureHttp400Code(mixed $code) : string
Parameters
$code : mixed
Return values
string

firstOrCreate()

Retrieves first element of the database. If it doesn't exists, it creates it before returning it.

public firstOrCreate(array<string|int, mixed> $data) : object
Parameters
$data : array<string|int, mixed>
  • Data of the object that we want to create.
Tags
throws
Exception
Return values
object

firstOrNew()

Retrieves first element of the database. If it doesn't exists, it instanciates it before returning it.

public firstOrNew(array<string|int, mixed> $data) : object
Parameters
$data : array<string|int, mixed>
  • Data of the object that we want to create.
Tags
throws
Exception
Return values
object

forceDelete()

It definitely removes a record from the database

public forceDelete(array<string|int, mixed> $data, int $id) : bool
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to delete.
$id : int
  • Id of the object that we want to remove.
Tags
desc

Force delete record from the database

Return values
bool
  • Success or fail

getAccessToken()

public getAccessToken(int $id) : bool
Parameters
$id : int
  • Id of the object that we want to remove.
Tags
desc

Force delete record from the database

Return values
bool
  • Success or fail

getAgency()

public getAgency(mixed $agency) : string
Parameters
$agency : mixed
Tags
desc

Retrieves an agency by access_token or id

Return values
string

getConcatString()

Concatenate string to make it compatible with SQLite

public getConcatString( $firstField,  $secondField[,  $concatCharacter = ' ' ]) : string
Parameters
$firstField :

to concat

$secondField :

to concat

$concatCharacter : = ' '

Character used to join fields, default is space

Return values
string

getErrorResponse()

Return all an array of errors like validation in one format

public getErrorResponse(mixed $message[, mixed $code = null ]) : array<string|int, mixed>
Parameters
$message : mixed
$code : mixed = null
Return values
array<string|int, mixed>

getFailResponse()

Return all an array of errors like validation in one format

public getFailResponse(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
  • Array with parameters
Return values
array<string|int, mixed>

getModel()

Get the associated model

public getModel() : Model
Return values
Model

$model - A specific model

getPaymentMethods()

public getPaymentMethods(int $id) : string
Parameters
$id : int
  • Id of the object that we want to remove.
Tags
desc

Force delete record from the database

throws
Exception
Return values
string
  • Success or fail

getSuccessResponse()

Return all an array of errors like validation in one format

public getSuccessResponse([array<string|int, mixed> $data = "" ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed> = ""
  • Array with parameters
Return values
array<string|int, mixed>

licenses()

public licenses(int $id) : string
Parameters
$id : int
  • Id of the object that we want to update.
Tags
desc

Add license to agency

Return values
string

licenses_store()

public licenses_store(array<string|int, mixed> $data, int $id) : string
Parameters
$data : array<string|int, mixed>
$id : int
  • Id of the object that we want to update.
Tags
desc

Add license to agency

Return values
string

microsecondsToSeconds()

Return all an array of errors like validation in one format

public microsecondsToSeconds(mixed $microseconds) : array<string|int, mixed>
Parameters
$microseconds : mixed
Return values
array<string|int, mixed>

mime2ext()

Return a extension from mimetype

public mime2ext(string $mime) : string
Parameters
$mime : string
  • String with mimetype
Return values
string

modules()

public modules(mixed $agency_id, mixed $user_id) : object
Parameters
$agency_id : mixed
$user_id : mixed
Tags
desc

Show the record with the given id

Return values
object

orderQuery()

Destroy record from the database

public orderQuery(mixed &$query, array<string|int, mixed> $params) : null
Parameters
$query : mixed
$params : array<string|int, mixed>
  • Array with the pagination params
Return values
null

paginate()

public paginate(mixed $paginationLimit) : Model
Parameters
$paginationLimit : mixed
Tags
desc

Get items with pagination

Return values
Model

$model - N instances of mode

renewAccessToken()

public renewAccessToken(int $id) : bool
Parameters
$id : int
  • Id of the object that we want to remove.
Tags
desc

Force delete record from the database

Return values
bool
  • Success or fail

sendMail()

Send an email

public sendMail( $mail, string $toEmail[, string $bccEmail = null ]) : bool
Parameters
$mail :
  • Mailable extended class to send
$toEmail : string
  • Delivery address
$bccEmail : string = null
  • Black carbon copy address
Return values
bool

setModel()

Set the associated model

public setModel(Model $model) : mixed
Parameters
$model : Model
  • A specific model
Return values
mixed

show()

Show the record with the given id

public show(int $id) : object
Parameters
$id : int
  • Id of the object that we want to show.
Tags
desc

Show the record (Agency) with the given id

Return values
object

showFromAccessToken()

public showFromAccessToken(mixed $access_token) : object
Parameters
$access_token : mixed
Tags
desc

Show the record with the given id

Return values
object

showWith()

Eager load database relationships

public showWith(mixed $id, string $relations) : Model
Parameters
$id : mixed
$relations : string
  • A name of relations to add
Return values
Model

$model - A specific model

store()

public store(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
  • Data of the object that we want to create.
Tags
desc

Create a new record in the database

Return values
array<string|int, mixed>

update()

Updates a record in the database

public update(array<string|int, mixed> $data, int $id) : object
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to update.
$id : int
  • Id of the object that we want to update.
Tags
desc

Update record in the database

Return values
object

updatePaymentMethods()

public updatePaymentMethods(array<string|int, mixed> $data, int $id) : bool
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to delete.
$id : int
  • Id of the object that we want to remove.
Tags
desc

Force delete record from the database

Return values
bool
  • Success or fail

updatePermissions()

public updatePermissions(array<string|int, mixed> $data, mixed $agency_id, mixed $user_id) : object
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to update.
$agency_id : mixed
$user_id : mixed
Tags
desc

Update record in the database

Return values
object

users()

public users(int $id) : string
Parameters
$id : int
  • Id of the object that we want to update.
Tags
desc

Get all users of the agency

Return values
string

users_delete()

public users_delete(int $id, mixed $user_id) : string
Parameters
$id : int
  • Id of the object that we want to update.
$user_id : mixed
Tags
desc

Remove user from agency

Return values
string
public users_link(array<string|int, mixed> $data, int $id) : string
Parameters
$data : array<string|int, mixed>
$id : int
  • Id of the object that we want to update.
Tags
desc

Add user to agency

Return values
string

users_show()

public users_show(int $agency_id, mixed $user_id) : object
Parameters
$agency_id : int
  • Id of the agency that we want to query.
$user_id : mixed
Tags
desc

Show the record with the given id

Return values
object

users_store()

public users_store(array<string|int, mixed> $data, int $id) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>
$id : int
  • Id of the object that we want to update.
Tags
desc

Add user to agency

Return values
array<string|int, mixed>

users_update()

public users_update(array<string|int, mixed> $data, int $agency_id, int $user_id) : object
Parameters
$data : array<string|int, mixed>
  • Datas of the object that we want to update.
$agency_id : int
  • Id of the agency that we want to query.
$user_id : int
  • Id of the object that we want to update.
Tags
desc

Update record in the database

Return values
object

Search results