Documentation

TravelRepository extends Repository

Table of Contents

PAGINATION_LIMIT  = 15
RESPONSE_STATUS_ERROR  = 'error'
RESPONSE_STATUS_FAIL  = 'fail'
RESPONSE_STATUS_SUCCESS  = 'success'
$agencyRepo  : mixed
$model  : mixed
Model var
$repo  : mixed
Repo var
__construct()  : mixed
all()  : array<string|int, mixed>
Get all instances of model
allChild()  : string
Return all database records
allCustom()  : string
Return database records paginated
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
deleteChild()  : string
Delete 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
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
getSuccessResponse()  : array<string|int, mixed>
Return all an array of errors like validation in one format
microsecondsToSeconds()  : array<string|int, mixed>
Return all an array of errors like validation in one format
mime2ext()  : string
Return a extension from mimetype
orderQuery()  : null
Destroy record from the database
paginate()  : Model
participants2Excel()  : mixed
picture_add()  : string
Adds a new picture
picture_delete()  : string
Deletes a picture
picture_principal()  : string
Set a picture as main picture
printParticipants()  : mixed
publicIndex()  : array<string|int, mixed>
Return a specific travel in public part according to its uuid
publicShow()  : array<string|int, mixed>
Return a specific travel in public part according to its uuid
reorder()  : array<string|int, mixed>
It reorders a travel by its custom_order field.
sendMail()  : bool
Send an email
setModel()  : mixed
Set the associated model
show()  : object
Show the record with the given id
showChild()  : object
Show the record with the given id
showWith()  : Model
Eager load database relationships
storeChild()  : string
Create a new record in the database
update()  : object
Updates a record in the database
updateChild()  : string
Update record from the database
savePictures()  : string

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

all()

Get all instances of model

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

allChild()

Return all database records

public allChild(int $parent_id) : string
Parameters
$parent_id : int
  • Id of the parent objects that we want to get.
Tags
throws
Exception
Return values
string

allCustom()

Return database records paginated

public allCustom(int $data, int $parent_id) : string
Parameters
$data : int
  • Filters data.
$parent_id : int
  • Id of the parent objects that we want to get.
Tags
throws
Exception
Return values
string

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>
$id : int
  • Id of the object that we want to remove.
Tags
throws
Exception
Return values
bool
  • Success or fail

deleteChild()

Delete record from the database

public deleteChild(array<string|int, mixed> $data, int $parent_id, int $id) : string

After deletion we sort again all deleted elements so custom_order doesn't collide with non-deleted travels and we can reorder them easily.

We add a +2 to the deleted elements so when we re order active travels, there is one space left to increase by 1 before moving the new object.

Parameters
$data : array<string|int, mixed>
$parent_id : int
  • Id of the parent object that we want to delete.
$id : int
  • Id of the object that we want to delete.
Tags
throws
ValidationException
Return values
string

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>
$id : int
  • Id of the object that we want to remove.
Tags
throws
Exception
Return values
bool
  • Success or fail

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

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>

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

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

participants2Excel()

public participants2Excel( $data,  $agency_id, mixed $id) : mixed
Parameters
$data :
$agency_id :
$id : mixed
Tags
desc

Exports to Excel a list of participants in all BookingPackages' bookings

Return values
mixed

For a given travel code, it searches all packages for that code, and lists participants for that package's booking, returning a PDF

picture_add()

Adds a new picture

public picture_add(array<string|int, mixed> $data,  $agency_id,  $travel_id) : string
Parameters
$data : array<string|int, mixed>
$agency_id :
$travel_id :
Tags
throws
ValidationException
Return values
string

picture_delete()

Deletes a picture

public picture_delete(array<string|int, mixed> $data,  $agency_id,  $travel_id,  $picture_id) : string
Parameters
$data : array<string|int, mixed>
$agency_id :
$travel_id :
$picture_id :
Tags
throws
Exception
Return values
string

picture_principal()

Set a picture as main picture

public picture_principal(array<string|int, mixed> $data,  $agency_id,  $travel_id,  $picture_id) : string
Parameters
$data : array<string|int, mixed>
$agency_id :
$travel_id :
$picture_id :
Tags
throws
Exception
Return values
string

printParticipants()

public printParticipants( $data,  $agency_id, mixed $id) : mixed
Parameters
$data :
$agency_id :
$id : mixed
Tags
desc

Prints a list of participants in all BookingPackages' bookings

Return values
mixed

For a given travel code, it searches all packages for that code, and lists participants for that package's booking, returning a PDF

publicIndex()

Return a specific travel in public part according to its uuid

public publicIndex(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

access_token = token of the agency wich data has to be shown in public part. mainpage - attribute received to know if travels with public_visibility have to be shown (optional) category - attribute received to discriminate travels with travel_categoies (optional)

Tags
throws
ValidationException
  • in case parameters are not correct
Return values
array<string|int, mixed>
  • returns travels from agency related via access_token

publicShow()

Return a specific travel in public part according to its uuid

public publicShow(array<string|int, mixed> $data,  $uuid) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

access_token = token of the agency wich data has to be shown in public part. language = [es,en,de] language for the translation system (optional)

$uuid :
  • identifies travel to be shown
Tags
throws
Exception
  • in case we don't find the travel with uuid received
Return values
array<string|int, mixed>
  • returns travel instance as an array plus boards_upgrades' array manually added on it

reorder()

It reorders a travel by its custom_order field.

public reorder(array<string|int, mixed> $data,  $agency_id,  $travel_id) : array<string|int, mixed>

If we move an element backward (from position 5 to 2) we increase by one and replace that exact element.

If we move an element forward (from position 2 to 5) we want to put the element AFTER it, if we don't do it, we will se the element in one position behind where we pretended.

Parameters
$data : array<string|int, mixed>
$agency_id :
$travel_id :
Tags
throws
Exception
Return values
array<string|int, mixed>

travel

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.
Return values
object

showChild()

Show the record with the given id

public showChild( $parent_id, int $id) : object
Parameters
$parent_id :
$id : int
  • Id of the object that we want to show.
Tags
throws
Exception
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

storeChild()

Create a new record in the database

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

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
throws
Exception
Return values
object

updateChild()

Update record from the database

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

savePictures()

private savePictures( $file,  $travel, int $isPrincipal) : string
Parameters
$file :
$travel :
$isPrincipal : int
Tags
desc

Save the pictures

Return values
string

Search results