Lead create Booking
This commit is contained in:
parent
3df0e93c2c
commit
34a3d2196b
18 changed files with 462 additions and 160 deletions
|
|
@ -4,9 +4,11 @@ namespace App\Repositories;
|
|||
|
||||
|
||||
use App\Models\Lead;
|
||||
use App\Models\Booking;
|
||||
use App\Models\LeadNotice;
|
||||
use App\Models\LeadParticipant;
|
||||
use App\Models\Participant;
|
||||
use App\Models\StatusHistory;
|
||||
use App\Models\LeadParticipant;
|
||||
|
||||
class LeadRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -120,5 +122,81 @@ class LeadRepository extends BaseRepository {
|
|||
return $this->model;
|
||||
}
|
||||
|
||||
public function createBooking($id, $data){
|
||||
$this->model = Lead::findOrFail($id);
|
||||
|
||||
if ($this->model->bookings->count() > 0){
|
||||
abort(403, 'Die Anfrage hat bereits eine Buchnung.');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'booking_date' => date('Y-m-d'), //now
|
||||
'customer_id' => $this->model->customer->id,
|
||||
'lead_id' => $this->model->id,
|
||||
'new_drafts' => 1,
|
||||
'sf_guard_user_id' => $this->model->sf_guard_user_id,
|
||||
'branch_id' => 4,
|
||||
'pax' => $this->model->pax,
|
||||
'title' => "",
|
||||
'comfort' => false,
|
||||
'start_date' => $this->model->travelperiod_start,
|
||||
'end_date' => $this->model->travelperiod_end,
|
||||
'website_id' => 1,
|
||||
'travel_number' => null,
|
||||
'participant_name' => null,
|
||||
'participant_firstname' => null,
|
||||
'participant_birthdate' => null,
|
||||
'participant_salutation_id' => null,
|
||||
'nationality_id' => null,
|
||||
'price' => $this->model->price,
|
||||
'price_total' => null,
|
||||
'deposit_total' => null,
|
||||
'final_payment' => null,
|
||||
'final_payment_date' => null,
|
||||
'travel_country_id' => $this->model->travelcountry_id,
|
||||
'travel_category_id' => $this->model->travelcategory_id,
|
||||
'travelagenda_id' => $this->model->travelagenda_id,
|
||||
'travel_company_id' => 4,
|
||||
];
|
||||
|
||||
//createBooking
|
||||
$booking = Booking::create($data);
|
||||
|
||||
// copy participants
|
||||
if($this->model->lead_participants){
|
||||
foreach($this->model->lead_participants as $participant){
|
||||
Participant::create([
|
||||
'booking_id' => $booking->id,
|
||||
'participant_name' => $participant->participant_name,
|
||||
'participant_firstname' => $participant->participant_firstname,
|
||||
'participant_birthdate' => $participant->participant_birthdate,
|
||||
'participant_salutation_id' => $participant->participant_salutation_id,
|
||||
'participant_child' => $participant->participant_child,
|
||||
'nationality_id' => $participant->nationality_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//inquiries
|
||||
//offers ???
|
||||
/*if($lead->getInquiry()->count() > 0)
|
||||
{
|
||||
foreach($lead->getInquiry() as $inquiry)
|
||||
{
|
||||
$arrangement = new Arrangement();
|
||||
$arrangement->setArrangementType($inquiry->getInquiryType()->getArrangementType());
|
||||
$arrangement->setBegin($inquiry->getBegin());
|
||||
$arrangement->setEnd($inquiry->getEnd());
|
||||
$arrangement->setDataS($inquiry->getDataS());
|
||||
$arrangement->setInPdf($inquiry->getInPdf());
|
||||
$arrangement->setBooking($booking);
|
||||
$arrangement->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue