BookingRepository extends Repository
Table of Contents
- RESPONSE_STATUS_ERROR = 'error'
- RESPONSE_STATUS_FAIL = 'fail'
- RESPONSE_STATUS_SUCCESS = 'success'
- $childRelationName : mixed
- $model : mixed
- $parentRepo : mixed
- $repo : mixed
- __construct() : object
- all() : array<string|int, mixed>
- allBoundedByDates() : array<string|int, mixed>
- Create a list from all bookings within start and end date
- allChild() : string
- availableSlots() : array<string|int, mixed>
- Show the service´s schedule
- bookingAbsence() : Booking
- Save an employee absence
- bookingAbsenceUpdate() : Booking
- Change a pass booking status as absence
- bookingAccept() : Booking
- Accept a booking from the database
- bookingCancel() : Booking
- Cancels a booking from the database
- bookingConfirm() : Booking
- Confirms a booking from the database
- bookingReject() : Booking
- Rejects a booking from the database
- cleanNullValues() : null
- Change null values and put string("")
- delete() : bool
- deleteBookingAbsence() : Booking
- delete an employee absence from database
- deleteChild() : bool
- ensureHttp400Code() : string
- Return a extension from mimetype
- firstOrCreate() : object
- firstOrNew() : object
- forceDelete() : bool
- getCustomLabelFormat() : array<string|int, mixed>
- Return an array with custom label format
- 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
- getObject() : array<string|int, mixed>
- getSuccessResponse() : array<string|int, mixed>
- Return all an array of errors like validation in one format
- getUserStore() : mixed
- mime2ext() : string
- Return a extension from mimetype
- orderQuery() : null
- Destroy record from the database
- paginate() : array<string|int, mixed>
- paginateChild() : array<string|int, mixed>
- setModel() : mixed
- show() : object
- Show the record with the given id
- showChild() : object
- store() : Booking
- Store a booking to the database
- storeChild() : object
- update() : Booking
- Update booking from the database
- updateAbsenceComment() : Booking
- Update internal_comment from absence
- updateChild() : object
- updateStatus() : Booking
- Update status from booking given by id
- bookingType() : array<string|int, mixed>
- generate booking data
- bookOtherBookings() : mixed
- checkValidSchedule() : bool
- Check valid schedule day employee
- chooseEmployeeBooking() : array<string|int, mixed>|null
- Get first employee and hour available
- employeeServiceValidation() : bool
- Take all employee´s booking and take his duration
- getEmployeeSchedule() : Collection
- Prepare the schedule from a employeee
- storeAndEmployeeValidation() : bool
- Validate date with employee and store timetable
- validationRules() : array<string|int, mixed>
- Validation rules
- validationStatus() : array<string|int, mixed>
- Validation rules for status
Constants
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
$childRelationName
protected
mixed
$childRelationName
$model
protected
mixed
$model
$parentRepo
protected
mixed
$parentRepo
$repo
protected
mixed
$repo
Methods
__construct()
public
__construct(Booking $model) : object
Parameters
- $model : Booking
-
- A specific model
Return values
object —all()
public
all(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Tags
Return values
array<string|int, mixed> —allBoundedByDates()
Create a list from all bookings within start and end date
public
allBoundedByDates(Request $request, $start_date, $end_date) : array<string|int, mixed>
The call give a list with all bookings within start and end date. The customers and employees only can see their own bookings
Parameters
Return values
array<string|int, mixed> —allChild()
public
allChild(Request $request, int $parent_id) : string
Parameters
- $request : Request
- $parent_id : int
-
- Id of the parent objects that we want to get.
Tags
Return values
string —availableSlots()
Show the service´s schedule
public
availableSlots(Request $request[, bool $returnFirst = false ]) : array<string|int, mixed>
show a schedule from a services and a employee or employees if dont pass a employee uuid, show all employee from that service
Parameters
- $request : Request
-
- Data of the object that we want to update.
- $returnFirst : bool = false
-
- Return the first available slot found.
Tags
Return values
array<string|int, mixed> —bookingAbsence()
Save an employee absence
public
bookingAbsence(Request $request) : Booking
Only store´s manager can safe this data from his stores' booking
Parameters
- $request : Request
-
- Data of the object that we want to update.
Return values
Booking —updated booking object
bookingAbsenceUpdate()
Change a pass booking status as absence
public
bookingAbsenceUpdate(Request $request, $id) : Booking
Only store´s manager can safe this data from his stores' booking
Parameters
- $request : Request
-
- Data of the object that we want to update.
- $id :
-
- Id of the booking that we want to update.
Return values
Booking —updated booking object
bookingAccept()
Accept a booking from the database
public
bookingAccept( $uuid, $token) : Booking
Parameters
- $uuid :
-
- uuid of the booking that we want to confirm.
- $token :
-
- unique token used to verify the request
Return values
Booking —bookingCancel()
Cancels a booking from the database
public
bookingCancel( $uuid, $token) : Booking
Parameters
- $uuid :
-
- uuid of the booking that we want to confirm.
- $token :
-
- unique token used to verify the request
Return values
Booking —bookingConfirm()
Confirms a booking from the database
public
bookingConfirm( $uuid, $token) : Booking
Parameters
- $uuid :
-
- uuid of the booking that we want to confirm.
- $token :
-
- unique token used to verify the request
Return values
Booking —bookingReject()
Rejects a booking from the database
public
bookingReject( $uuid, mixed $token) : Booking
Parameters
Return values
Booking —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 —delete()
public
delete(Request $request, int $id) : bool
Parameters
- $request : Request
- $id : int
-
- Id of the object that we want to remove.
Tags
Return values
bool —- Success or fail
deleteBookingAbsence()
delete an employee absence from database
public
deleteBookingAbsence(Request $request, $id) : Booking
Only store´s manager can delete this data from his stores' booking
Parameters
- $request : Request
-
- Data of the object that we want to update.
- $id :
-
- Id of the booking that we want to update.
Return values
Booking —updated booking object
deleteChild()
public
deleteChild(Request $request, mixed $parent_id, int $id) : bool
Parameters
- $request : Request
- $parent_id : mixed
- $id : int
-
- Id of the object that we want to remove.
Tags
Return values
bool —- Success or fail
ensureHttp400Code()
Return a extension from mimetype
public
ensureHttp400Code(mixed $code) : string
Parameters
- $code : mixed
Return values
string —firstOrCreate()
public
firstOrCreate(Request $request) : object
Parameters
- $request : Request
Tags
Return values
object —firstOrNew()
public
firstOrNew(Request $request) : object
Parameters
- $request : Request
Tags
Return values
object —forceDelete()
public
forceDelete(Request $request, int $id) : bool
Parameters
- $request : Request
- $id : int
-
- Id of the object that we want to remove.
Tags
Return values
bool —- Success or fail
getCustomLabelFormat()
Return an array with custom label format
public
getCustomLabelFormat(string $customLabel[, array<string|int, mixed> $data = NULL ]) : array<string|int, mixed>
Parameters
- $customLabel : string
-
- New response label
- $data : array<string|int, mixed> = NULL
-
- Response datas
Return values
array<string|int, mixed> —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()
public
getModel() : Model
Tags
Return values
Model —$model - A specific model
getObject()
public
getObject(mixed $id) : array<string|int, mixed>
Parameters
- $id : mixed
Tags
Return values
array<string|int, mixed> —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> —getUserStore()
public
getUserStore() : mixed
Tags
Return values
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(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Tags
Return values
array<string|int, mixed> —paginateChild()
public
paginateChild(Request $request, mixed $parent_id) : array<string|int, mixed>
Parameters
- $request : Request
- $parent_id : mixed
Tags
Return values
array<string|int, mixed> —setModel()
public
setModel(Model $model) : mixed
Parameters
- $model : Model
-
- A specific model
Tags
Return values
mixed —show()
Show the record with the given id
public
show(Request $request, int $id) : object
The call give the data from one booking The customers and employees only can see their bookings
Parameters
- $request : Request
- $id : int
-
- Id of the object that we want to show.
Return values
object —showChild()
public
showChild(Request $request, mixed $parent_id, int $id) : object
Parameters
- $request : Request
- $parent_id : mixed
- $id : int
-
- Id of the object that we want to show.
Tags
Return values
object —store()
Store a booking to the database
public
store(Request $request) : Booking
Parameters
- $request : Request
-
- Data of the object that we want to save.
Tags
Return values
Booking —- created object
storeChild()
public
storeChild(Request $request, mixed $parent_id) : object
Parameters
- $request : Request
- $parent_id : mixed
Tags
Return values
object —update()
Update booking from the database
public
update(Request $request, int $id) : Booking
Only store´s manager can update data from his stores' booking An employee or customer can update his bookings
Parameters
- $request : Request
-
- Data of the object that we want to update.
- $id : int
-
- Id of the booking that we want to update.
Return values
Booking —updated booking object
updateAbsenceComment()
Update internal_comment from absence
public
updateAbsenceComment(Request $request, $id) : Booking
Only store´s manager can update data from absences
Parameters
- $request : Request
-
- Data of the object that we want to update.
- $id :
-
- Id of the booking that we want to update.
Return values
Booking —updated booking object
updateChild()
public
updateChild(Request $request, mixed $parent_id, int $id) : object
Parameters
- $request : Request
- $parent_id : mixed
- $id : int
-
- Id of the object that we want to update.
Tags
Return values
object —updateStatus()
Update status from booking given by id
public
updateStatus(Request $request, $id, mixed $oldStatus) : Booking
Only store´s manager can update data from his stores' booking An employee or customer can update his bookings
Parameters
- $request : Request
-
- Datas of the object that we want to update.
- $id :
-
- Id of the booking that we want to update.
- $oldStatus : mixed
Tags
Return values
Booking —updated booking object
bookingType()
generate booking data
private
bookingType(Request $request[, $booking = null ][, mixed $absence = false ]) : array<string|int, mixed>
Parameters
- $request : Request
-
- data of the object.
- $booking : = null
-
- if we want to validate a reservation which we are updating, make sure that it does not validate itself.
- $absence : mixed = false
Tags
Return values
array<string|int, mixed> —bookOtherBookings()
private
bookOtherBookings(mixed $request, mixed $booking, mixed $customer) : mixed
Parameters
- $request : mixed
- $booking : mixed
- $customer : mixed
Return values
mixed —checkValidSchedule()
Check valid schedule day employee
private
checkValidSchedule(string $scheduleEmployee, string $currentDay) : bool
Parameters
- $scheduleEmployee : string
-
- Date of valid_schedule database employee.
- $currentDay : string
-
- current day of bucle.
Return values
bool —chooseEmployeeBooking()
Get first employee and hour available
private
chooseEmployeeBooking( $request, mixed $serviceUuid, $datetime) : array<string|int, mixed>|null
Parameters
Tags
Return values
array<string|int, mixed>|null —employeeServiceValidation()
Take all employee´s booking and take his duration
private
employeeServiceValidation(string $date, object $service, object $employee[, object $bookingBeingEdited = null ]) : bool
Parameters
- $date : string
-
- day we want to validate.
- $service : object
-
- service to which the validation will be done.
- $employee : object
-
- employee to which the validation will be done.
- $bookingBeingEdited : object = null
-
- if we want to validate a reservation which we are updating, make sure that it does not validate itself.
Tags
Return values
bool —getEmployeeSchedule()
Prepare the schedule from a employeee
private
getEmployeeSchedule(array<string|int, mixed> $storeClosingDays, Collection $storeServices, object $employee, array<string|int, mixed> $employeeDaysOff, mixed $allEmployeeWorkingHours, object $employeeBookings, string $start, mixed $end, number $serviceDuration, number $appointmentGap, mixed $timeRestriction, Collection $scheduleEmployee, bool $returnFirst) : Collection
Parameters
- $storeClosingDays : array<string|int, mixed>
-
- Days when the store is closed.
- $storeServices : Collection
-
- Services given by the store.
- $employee : object
-
- Employee we want take the schedule.
- $employeeDaysOff : array<string|int, mixed>
-
- Employee days off.
- $allEmployeeWorkingHours : mixed
- $employeeBookings : object
-
- Employee bookings we want to filter.
- $start : string
-
- Initial day of the interval.
- $end : mixed
- $serviceDuration : number
-
- Service duration on minutes.
- $appointmentGap : number
-
- Gap between services.
- $timeRestriction : mixed
- $scheduleEmployee : Collection
-
- if we need add employees, we will use the object formed above.
- $returnFirst : bool
-
- whether we want to return the first available slot
Return values
Collection —storeAndEmployeeValidation()
Validate date with employee and store timetable
private
storeAndEmployeeValidation(string $date, object $store, object $service, object $employee[, object $booking = null ]) : bool
Parameters
- $date : string
-
- day we want to validate.
- $store : object
-
- store to which the validation will be done.
- $service : object
-
- service to which the validation will be done.
- $employee : object
-
- employee to which the validation will be done.
- $booking : object = null
-
- if we want to validate a reservation which we are updating, make sure that it does not validate itself.
Tags
Return values
bool —validationRules()
Validation rules
private
validationRules(mixed $request[, mixed $bookingId = null ]) : array<string|int, mixed>
Parameters
- $request : mixed
- $bookingId : mixed = null
Return values
array<string|int, mixed> —validationStatus()
Validation rules for status
private
validationStatus(mixed $request, mixed $oldStatus) : array<string|int, mixed>
Parameters
- $request : mixed
- $oldStatus : mixed