VehicleRepository 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
- allCustom() : Collection
- Private endpoint that shows a list of vehicles for a given date range and car rental office
- checkRangeDaysIncorrect() : void
- Check if there are repeated days in the same range of days and generates an exception.
- 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
- deleteBlockedPlateDates() : null
- deleteChild() : string
- Delete record from the database
- ensureHttp400Code() : string
- Return a extension from mimetype
- excelDownload() : mixed
- 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
- getAcrissCode() : mixed
- getBlockedVehiclePlate() : mixed
- 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
- getVehiclePlates() : mixed
- 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
- publicIndex() : array<string|int, mixed>
- Public endpoint that lists all vehicles for a given date range and car rental office
- publicShow() : object
- Public endpoint that shows one vehicle for a given date range and car rental office
- searchBookedVehicles() : mixed
- searchVehicleForBookings() : Collection
- Private endpoint that shows a list of vehicles for a given date range and car rental office
- sendMail() : bool
- Send an email
- setModel() : mixed
- Set the associated model
- show() : object
- Show the record with the given id
- showCustom() : object
- Private endpoint that shows one vehicle for a given date range and car rental office
- showWith() : Model
- Eager load database relationships
- storeBlockedPlateDates() : mixed
- storeChild() : string
- Create a new record in the database
- update() : object
- Updates a record in the database
- updateChild() : object
- Update record from the database
- checkDifferentDestination() : bool|null
- Verifies if the rented vehicle is returned in a different state
- getAvailableVehicle() : mixed
- getAvailableVehiclePlates() : mixed
- savePicture() : null
- Saves and updates a picture for a given vehicle.
- vehiclesWithPriceAndCommision() : mixed
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
$agencyRepo
protected
mixed
$agencyRepo
$model
Model var
protected
mixed
$model
$repo
Repo var
protected
mixed
$repo
Methods
__construct()
public
__construct(Vehicle $model) : mixed
Parameters
- $model : Vehicle
Return values
mixed —all()
Get all instances of model
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed> —allCustom()
Private endpoint that shows a list of vehicles for a given date range and car rental office
public
allCustom(array<string|int, mixed> $data, $parent_id) : Collection
For a given pick_up_office_id and return_office_id in a date range, it returns all available vehicles in the pick_up_office (vehicles related) and return_office (same rental_company as pick_up_office) If pick_up_office_id and start_date is received, it verifies also if the location(VehicleOffice) is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule)
Start and end dates are optional as long as both are added. You can't just ask for a start date, you need a return date. If start and return dates are provided, you get custom prices and commission for that date range. If start_date is received with pick_up_office_id, the function shows vehicles only which their car_rental_office is open at that datetime (start_date). This way we ensure that the picking up place is open for the client to collect his vehicle. So if pick_up_office_id and start_date is received, it verifies if the location is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule)
Parameters
- $data : array<string|int, mixed>
-
[ 'vehicle_location_id' => 'required: ID for the picking up rental office', 'start_date' => 'required only if a end date is given', 'end_date' => 'required only if a start date is given', 'type' => 'optional: Must exist in vehicleTypes', 'subtype' => 'optional: Must exist in vehicleSubtypes', 'vat_included' => 'optional: boolean', 'pick_up_office_id => 'optional - needed if vehicle is returned to a different office, 'return_office_id => 'optional - needed if vehicle is returned to a different office ] - $parent_id :
-
- Agency ID
Tags
Return values
Collection —of Vehicle according to parameters given
checkRangeDaysIncorrect()
Check if there are repeated days in the same range of days and generates an exception.
public
checkRangeDaysIncorrect( $prices) : void
Parameters
Tags
Return values
void —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
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
Return values
bool —- Success or fail
deleteBlockedPlateDates()
public
deleteBlockedPlateDates(array<string|int, mixed> $data, $parent_id, $vehicle_id, $id) : null
Parameters
Tags
Return values
null —deleteChild()
Delete record from the database
public
deleteChild(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 delete.
- $id : int
-
- Id of the object that we want to delete.
Tags
Return values
string —ensureHttp400Code()
Return a extension from mimetype
public
ensureHttp400Code(mixed $code) : string
Parameters
- $code : mixed
Return values
string —excelDownload()
public
excelDownload(mixed $agency_id) : mixed
Parameters
- $agency_id : mixed
Return values
mixed —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
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
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
Return values
bool —- Success or fail
getAcrissCode()
public
getAcrissCode() : mixed
Return values
mixed —getBlockedVehiclePlate()
public
getBlockedVehiclePlate(array<string|int, mixed> $data, $parent_id, $id) : mixed
Parameters
Tags
Return values
mixed —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> —getVehiclePlates()
public
getVehiclePlates(array<string|int, mixed> $data, $parent_id, $id) : mixed
Parameters
Tags
Return values
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
Return values
Model —$model - N instances of mode
publicIndex()
Public endpoint that lists all vehicles for a given date range and car rental office
public
publicIndex(array<string|int, mixed> $data) : array<string|int, mixed>
For a given pick up and return places in a date range, it returns all available vehicles in the pick up place (vehicles related) and return_place (same rental_company as pick_up_place) If pick_up_place and start_date is received, it verifies also if the location(VehicleOffice) is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule) If VAT is required, it gets it for the pick up place. Start and end dates are optional as long as both are added. You can't just ask for a start date, you need a return date. If start and return dates are provided, you get custom prices and commission for that date range.
If vehicle is returned in a different office, it will add the vehicle's "one way cost" value.
If pick_up_place and start_date is received, it verifies if the location is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule)
It adds more info about prices for wordpress plugin $vehicle->vat , entire_price_vat_excluded and vat_amount
Parameters
- $data : array<string|int, mixed>
-
[ 'pick_up_place' => 'required: UUID for the pick up rental office', 'return_place' => 'required: UUID for teh return rental office', 'start_date' => 'required only if a end date is given', 'end_date' => 'required only if a start date is given', 'type' => 'optional: Must exist in vehicleTypes', 'subtype' => 'optional: Must exist in vehicleSubtypes', 'vat_included' => 'optional: boolean', 'driver_age' => 'optional: boolean', ]
Tags
Return values
array<string|int, mixed> —publicShow()
Public endpoint that shows one vehicle for a given date range and car rental office
public
publicShow(array<string|int, mixed> $data, mixed $uuid) : object
For a vehicle UUID, pick up and return places it shows a vehicle with its details. If VAT is required, it gets it for the pick up place. Start and end dates are optional as long as both are added. You can't just ask for a start date, you need a return date. If start and return dates are provided, you get custom prices and commission for that date range.
If vehicle is returned in a different office, it will add the vehicle's "one way cost" value.
Parameters
- $data : array<string|int, mixed>
-
[ 'pick_up_place' => 'required: UUID for the pick up rental office', 'return_place' => 'required: UUID for the return rental office', 'start_date' => 'required only if a end date is given', 'end_date' => 'required only if a start date is given', 'type' => 'optional: Must exist in vehicleTypes', 'vat_included' => 'optional: boolean', ] - $uuid : mixed
Tags
Return values
object —searchBookedVehicles()
public
searchBookedVehicles(array<string|int, mixed> $data, mixed $parent_id, mixed $id) : mixed
Parameters
- $data : array<string|int, mixed>
- $parent_id : mixed
- $id : mixed
Return values
mixed —searchVehicleForBookings()
Private endpoint that shows a list of vehicles for a given date range and car rental office
public
searchVehicleForBookings(array<string|int, mixed> $data, $parent_id) : Collection
For a given pick_up_office_id and return_office_id in a date range, it returns all available vehicles in the pick_up_office (vehicles related) and return_office (same rental_company as pick_up_office) If pick_up_office_id and start_date is received, it verifies also if the location(VehicleOffice) is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule)
Start and end dates are optional as long as both are added. You can't just ask for a start date, you need a return date. If start and return dates are provided, you get custom prices and commission for that date range. If start_date is received with pick_up_office_id, the function shows vehicles only which their car_rental_office is open at that datetime (start_date). This way we ensure that the picking up place is open for the client to collect his vehicle. So if pick_up_office_id and start_date is received, it verifies if the location is opened at that time (VehicleLocation -> VehicleOffice -> VehicleOfficeSchedule)
Parameters
- $data : array<string|int, mixed>
-
[ 'vehicle_location_id' => 'required: ID for the picking up rental office', 'start_date' => 'required only if a end date is given', 'end_date' => 'required only if a start date is given', 'type' => 'optional: Must exist in vehicleTypes', 'subtype' => 'optional: Must exist in vehicleSubtypes', 'vat_included' => 'optional: boolean', 'pick_up_office_id => 'optional - needed if vehicle is returned to a different office, 'return_office_id => 'optional - needed if vehicle is returned to a different office ] - $parent_id :
-
- Agency ID
Tags
Return values
Collection —of Vehicle according to parameters given
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 —showCustom()
Private endpoint that shows one vehicle for a given date range and car rental office
public
showCustom(array<string|int, mixed> $data, $parent_id, $id) : object
For a vehicle ID, and car rental office, it shows a vehicle with its details. If VAT is required, it gets it for the pick up place. Start and end dates are optional as long as both are added. You can't just ask for a start date, you need a return date. If start and return dates are provided, you get custom prices and commission for that date range.
Parameters
- $data : array<string|int, mixed>
-
[ 'vehicle_location_id' => 'required: ID for the pick up rental office', 'start_date' => 'required only if a end date is given', 'end_date' => 'required only if a start date is given', 'vat_included' => 'optional: boolean', ] - $parent_id :
- $id :
Tags
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
storeBlockedPlateDates()
public
storeBlockedPlateDates(array<string|int, mixed> $data, $parent_id, $vehicle_id, $id) : mixed
Parameters
Tags
Return values
mixed —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>
-
- Data of the object that we want to create.
- $parent_id : int
-
- Id of the parent object that we want to create.
Tags
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
Return values
object —updateChild()
Update record from the database
public
updateChild(array<string|int, mixed> $data, int $parent_id, int $id) : object
Parameters
- $data : array<string|int, mixed>
-
- Datas of the object that we want to update.
- $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
Return values
object —checkDifferentDestination()
Verifies if the rented vehicle is returned in a different state
private
checkDifferentDestination( $data[, bool $public = false ]) : bool|null
This is needed to calculate the vehicle company's extra fee for one way trips.
We first check different_destination in the route, as some routes needs to be forced to do this
calculation.
If the field is not present but it has pick_up_place, we'll continue with the calculations. This method is
used for public and private endpoints, that is why we need two different $queryField
If the endpoint that you are using has a vehicle_location_id, it will never be used here. You will need the
different_destination flag
Parameters
Return values
bool|null —getAvailableVehicle()
private
getAvailableVehicle( $vehicles, array<string|int, mixed> $data, mixed $isMonthlyRenewBooking) : mixed
Parameters
Tags
Return values
mixed —getAvailableVehiclePlates()
private
getAvailableVehiclePlates( $vehicles, $startDate, $endDate[, mixed $bookingVehicleExcluded = null ]) : mixed
Parameters
Tags
Return values
mixed —savePicture()
Saves and updates a picture for a given vehicle.
private
savePicture(Vehicle &$vehicle, $file) : null
This private endpoint creates or updates the picture of a given vehicle, removing the previous one from the storage.
Parameters
- $vehicle : Vehicle
-
- The element to upload
- $file :
-
- The file to upload
Tags
Return values
null —vehiclesWithPriceAndCommision()
private
vehiclesWithPriceAndCommision(mixed $data, mixed $vehicles[, mixed $public = false ]) : mixed
Parameters
- $data : mixed
- $vehicles : mixed
- $public : mixed = false