Store Customer, Store Booking details
This commit is contained in:
parent
b362b93bca
commit
6706d28f51
33 changed files with 1048 additions and 257 deletions
|
|
@ -69,6 +69,12 @@ class BookingController extends Controller
|
|||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
|
||||
}
|
||||
|
||||
if($data['action'] === 'save_lead_status'){
|
||||
$booking = $this->bookingRepo->updateLeadStatus($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingLead");
|
||||
}
|
||||
|
||||
if($data['action'] === 'update_booking'){
|
||||
$booking = $this->bookingRepo->updateBooking($id, $data);
|
||||
|
|
@ -76,15 +82,35 @@ class BookingController extends Controller
|
|||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingBooking");
|
||||
}
|
||||
|
||||
if($data['action'] === 'update_booking_services'){
|
||||
$booking = $this->bookingRepo->updateBookingServices($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingServices");
|
||||
}
|
||||
|
||||
if($data['action'] === 'update_booking_number'){
|
||||
$booking = $this->bookingRepo->updateBookingNumber($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingMyJack");
|
||||
}
|
||||
|
||||
if($data['action'] === 'update_booking_price'){
|
||||
$booking = $this->bookingRepo->updateBookingPrice($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingPrice");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($id === "new") {
|
||||
$booking = new Booking();
|
||||
}else{
|
||||
$booking = Booking::findOrFail($id);
|
||||
}
|
||||
|
||||
$booking->merlin_order_number = $data['merlin_order_number'];
|
||||
$booking->save();
|
||||
|
||||
// $booking->merlin_order_number = $data['merlin_order_number'];
|
||||
// $booking->save();
|
||||
$i = 1;
|
||||
|
||||
if($data['action'] === 'addItemUp'){
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use Request;
|
|||
class CustomerController extends Controller
|
||||
{
|
||||
|
||||
protected $customerRepo;
|
||||
protected $custRepo;
|
||||
|
||||
public function __construct(CustomerRepository $customerRepo)
|
||||
public function __construct(CustomerRepository $custRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerRepo = $customerRepo;
|
||||
$this->custRepo = $custRepo;
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
|
|
@ -46,12 +46,14 @@ class CustomerController extends Controller
|
|||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if($data['action'] === 'saveCustomer'){
|
||||
$customer = $this->custRepo->updateCustomer($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('customer_detail', [$id]).'#collapseCustomerDetail');
|
||||
}
|
||||
return back();
|
||||
/* $data = Request::all();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class CustomerFewoMailController extends Controller
|
|||
$this->customerMailRepo = $customerMailRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
/* public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class CustomerFewoMailController extends Controller
|
|||
];
|
||||
return view('customer.mail.detail', $data);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
public function store($id, $action=false)
|
||||
{
|
||||
|
|
@ -137,55 +137,6 @@ class CustomerFewoMailController extends Controller
|
|||
return back();
|
||||
}
|
||||
|
||||
/*public function getCustomerFewoMails()
|
||||
{
|
||||
$query = CustomerFewoMail::with('booking')->with('customer')->select('customer_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a href="'.route('customer_mail_detail', [$customer_mail->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->id.'" href="'.route('customer_mail_detail', [$customer_mail->id]).'" data-id="'.$customer_mail->id.'">'.$customer_mail->id.'</a>';
|
||||
})
|
||||
->addColumn('booking', function (CustomerFewoMail $customer_mail) {
|
||||
$out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | ";
|
||||
$out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-";
|
||||
return $out;
|
||||
})
|
||||
->addColumn('travel_user_booking_fewo_id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->travel_user_booking_fewo_id.'" href="'.route('booking_detail', [$customer_mail->travel_user_booking_fewo_id]).'">'.$customer_mail->travel_user_booking_fewo_id.'</a>';
|
||||
})
|
||||
->addColumn('customer_id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->customer_id.'" href="'.route('customer_detail', [$customer_mail->customer_id]).'">'.$customer_mail->customer_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (CustomerFewoMail $customer_mail) {
|
||||
return $customer_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_user_booking_fewo_id', 'travel_user_booking_fewo_id $1')
|
||||
->orderColumn('customer_id', 'customer_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('customer_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('travel_user_booking_fewo_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('travel_user_booking_fewo_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'customer_id', 'travel_user_booking_fewo_id', 'id'])
|
||||
->make(true);
|
||||
}*/
|
||||
|
||||
public function getEmailTemplates()
|
||||
{
|
||||
$query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class CustomerMailController extends Controller
|
|||
$this->customerMailRepo = $customerMailRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
/*public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ class CustomerMailController extends Controller
|
|||
];
|
||||
return view('customer.mail.detail', $data);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
public function store($id, $action=false)
|
||||
{
|
||||
|
|
@ -156,62 +156,6 @@ class CustomerMailController extends Controller
|
|||
return back();
|
||||
}
|
||||
|
||||
public function getCustomerMails()
|
||||
{
|
||||
$query = CustomerMail::with('booking')->with('customer')->select('customer_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (CustomerMail $customer_mail) {
|
||||
return '<a href="'.route('customer_mail_detail', [$customer_mail->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (CustomerMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->id.'" href="'.route('customer_mail_detail', [$customer_mail->id]).'" data-id="'.$customer_mail->id.'">'.$customer_mail->id.'</a>';
|
||||
})
|
||||
->addColumn('booking', function (CustomerMail $customer_mail) {
|
||||
$out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | ";
|
||||
$out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-";
|
||||
return $out;
|
||||
})
|
||||
->addColumn('booking_id', function (CustomerMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->booking_id.'" href="'.route('booking_detail', [$customer_mail->booking_id]).'">'.$customer_mail->booking_id.'</a>';
|
||||
})
|
||||
->addColumn('customer_id', function (CustomerMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->customer_id.'" href="'.route('customer_detail', [$customer_mail->customer_id]).'">'.$customer_mail->customer_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (CustomerMail $customer_mail) {
|
||||
return $customer_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('date', function (CustomerMail $customer_mail) {
|
||||
if($customer_mail->send){
|
||||
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
}
|
||||
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('booking_id', 'booking_id $1')
|
||||
->orderColumn('customer_id', 'customer_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('customer_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('booking_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'date', 'customer_id', 'booking_id', 'id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function getEmailTemplates()
|
||||
{
|
||||
$query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true);
|
||||
|
|
|
|||
|
|
@ -31,34 +31,6 @@ class LeadMailController extends Controller
|
|||
$this->leadMailRepo = $leadMailRepo;
|
||||
}
|
||||
|
||||
/*public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
];
|
||||
return view('customer.mail.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$lead_mail = new LeadMail();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$lead_mail = LeadMail::findOrFail($id);
|
||||
$id = $lead_mail->id;
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'lead_mail' => $lead_mail,
|
||||
'id' => $id,
|
||||
'back' => URL::previous(),
|
||||
];
|
||||
return view('customer.mail.detail', $data);
|
||||
|
||||
}*/
|
||||
|
||||
public function store($id, $action=false)
|
||||
{
|
||||
|
|
|
|||
170
app/Http/Controllers/MailController.php
Normal file
170
app/Http/Controllers/MailController.php
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use Response;
|
||||
use App\Models\LeadMail;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Models\CustomerFewoMail;
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function leads()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('mails.lead', $data);
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('mails.booking', $data);
|
||||
}
|
||||
|
||||
public function bookingFewos()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('mails.booking_fewo', $data);
|
||||
}
|
||||
|
||||
|
||||
public function leadDatatable()
|
||||
{
|
||||
$query = LeadMail::with('lead')->with('customer')->select('lead_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (LeadMail $lead_mail) {
|
||||
return '<a href="'.route('lead_detail', [$lead_mail->lead_id]).'#collapseLeadMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (LeadMail $lead_mail) {
|
||||
return '<a data-order="'.$lead_mail->lead_id.'" href="'.route('lead_detail', [$lead_mail->lead_id]).'#collapseLeadMails">'.$lead_mail->lead_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (LeadMail $lead_mail) {
|
||||
return $lead_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('date', function (LeadMail $lead_mail) {
|
||||
if($lead_mail->send){
|
||||
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$lead_mail->sent_at.'</span>';
|
||||
}
|
||||
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$lead_mail->sent_at.'</span>';
|
||||
})
|
||||
->orderColumn('lead_id', 'lead_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('lead_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('lead_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'date', 'lead_id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function bookingDatatable()
|
||||
{
|
||||
$query = CustomerMail::with('booking')->with('customer')->select('customer_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (CustomerMail $customer_mail) {
|
||||
return '<a href="'.route('booking_detail', [$customer_mail->booking_id]).'#collapseBookingMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('booking', function (CustomerMail $customer_mail) {
|
||||
$out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | ";
|
||||
$out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-";
|
||||
return $out;
|
||||
})
|
||||
->addColumn('booking_id', function (CustomerMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->booking_id.'" href="'.route('booking_detail', [$customer_mail->booking_id]).'#collapseBookingMails">'.$customer_mail->booking_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (CustomerMail $customer_mail) {
|
||||
return $customer_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('date', function (CustomerMail $customer_mail) {
|
||||
if($customer_mail->send){
|
||||
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
}
|
||||
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
})
|
||||
->orderColumn('booking_id', 'booking_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('booking_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'date', 'booking_id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
public function bookingFewoDatatable()
|
||||
{
|
||||
$query = CustomerFewoMail::with('booking')->with('customer')->select('customer_fewo_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (CustomerFewoMail $customer_fewo_mail) {
|
||||
return '<a href="'.route('travel_user_booking_fewo_detail', [$customer_fewo_mail->travel_user_booking_fewo_id]).'#collapseBookingMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('booking', function (CustomerFewoMail $customer_fewo_mail) {
|
||||
$out = ($customer_fewo_mail->booking && $customer_fewo_mail->booking->fewo_lodging) ? $customer_fewo_mail->booking->fewo_lodging->name : "-";
|
||||
return $out;
|
||||
})
|
||||
->addColumn('booking_id', function (CustomerFewoMail $customer_fewo_mail) {
|
||||
return '<a data-order="'.$customer_fewo_mail->travel_user_booking_fewo_id.'" href="'.route('travel_user_booking_fewo_detail', [$customer_fewo_mail->travel_user_booking_fewo_id]).'#collapseBookingMails">'.$customer_fewo_mail->travel_user_booking_fewo_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (CustomerFewoMail $customer_fewo_mail) {
|
||||
return $customer_fewo_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('date', function (CustomerFewoMail $customer_fewo_mail) {
|
||||
if($customer_fewo_mail->send){
|
||||
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$customer_fewo_mail->sent_at.'</span>';
|
||||
}
|
||||
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_fewo_mail->sent_at.'</span>';
|
||||
})
|
||||
->orderColumn('booking_id', 'booking_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('booking_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'date', 'booking_id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -331,7 +331,15 @@ class TravelUserBookingFewoController extends Controller
|
|||
});
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'travel_user', 'is_calendar', 'is_mail', 'booking_fewo_notice', 'action_delete'])
|
||||
->addColumn('last_fewo_email', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
//umbuchen
|
||||
if($travel_user_booking_fewo->customer_fewo_mails->count()){
|
||||
$fewo_mail = $travel_user_booking_fewo->customer_fewo_mail_last;
|
||||
return '<a data-order="'.$fewo_mail->getSentAtRaw().'" href="'.route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]).'#collapseLeadMails" data-order="'.$fewo_mail->sent_at.'"><span class="badge '.($fewo_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$fewo_mail->sent_at.'</span></a>';
|
||||
}
|
||||
return '<span data-order="">-</span>';
|
||||
})
|
||||
->rawColumns(['action_edit', 'travel_user', 'is_calendar', 'is_mail', 'booking_fewo_notice', 'last_fewo_email', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,15 +143,15 @@ class Customer extends Model
|
|||
}
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
return $this->hasMany(Booking::class, 'customer_id');
|
||||
}
|
||||
public function coupons()
|
||||
{
|
||||
return $this->hasMany(Coupon::class);
|
||||
return $this->hasMany(Coupon::class, 'customer_id');
|
||||
}
|
||||
public function leads()
|
||||
{
|
||||
return $this->hasMany(Lead::class);
|
||||
return $this->hasMany(Lead::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function getSalutation(){
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class CustomerFewoMail extends Model
|
|||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class);
|
||||
return $this->belongsTo(TravelUserBookingFewo::class, 'travel_user_booking_fewo_id');
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
namespace App\Repositories;
|
||||
|
||||
|
||||
use Auth;
|
||||
use App\Models\Lead;
|
||||
use App\Services\Util;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingNotice;
|
||||
use Auth;
|
||||
use App\Models\BookingCompanyService;
|
||||
use App\Models\BookingCountryService;
|
||||
use App\Models\BookingProviderService;
|
||||
|
|
@ -46,11 +48,37 @@ class BookingRepository extends BaseRepository {
|
|||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateLeadStatus($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
|
||||
if(isset($data['lead'])){
|
||||
$lead = $this->model->lead;
|
||||
if($lead->id != $data['lead']['id']){
|
||||
abort(500);
|
||||
}
|
||||
$lead->status_id = $data['lead']['status_id'];
|
||||
$lead->is_rebook = isset($data['lead']['is_rebook']) ? true : false;
|
||||
$lead->is_closed = isset($data['lead']['is_closed']) ? true : false;
|
||||
$lead->save();
|
||||
}
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateBooking($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
|
||||
$fill = [
|
||||
'sf_guard_user_id' => $data['sf_guard_user_id'],
|
||||
'booking_date' => $data['booking_date'] ? _reformat_date($data['booking_date']) : null,
|
||||
'travel_number' => $data['travel_number'],
|
||||
'travel_country_id' => $data['travel_country_id'] ? $data['travel_country_id'] : null,
|
||||
'travelagenda_id' => $data['travelagenda_id'] ? $data['travelagenda_id'] : null,
|
||||
'travel_category_id' => $data['travel_category_id'] ? $data['travel_category_id'] : null,
|
||||
'start_date' => $data['start_date'] ? _reformat_date($data['start_date']) : null,
|
||||
'end_date' => $data['end_date'] ? _reformat_date($data['end_date']) : null,
|
||||
'title' => $data['title'],
|
||||
'paying_out' => $data['paying_out'],
|
||||
'paying_out_status' => $data['paying_out_status'],
|
||||
'airline_id' => $data['airline_id'],
|
||||
|
|
@ -63,11 +91,17 @@ class BookingRepository extends BaseRepository {
|
|||
'filekey' => $data['filekey'],
|
||||
'is_rail_fly' => isset($data['is_rail_fly']) ? true : false,
|
||||
'notice' => $data['notice'],
|
||||
'ev_number' => $data['ev_number'],
|
||||
'merlin_order_number' => $data['merlin_order_number'],
|
||||
];
|
||||
|
||||
$this->model->fill($fill);
|
||||
$this->model->save();
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateBookingServices($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
if(isset($data['country_service'])){
|
||||
$this->updateCountryService($data['country_service']);
|
||||
}
|
||||
|
|
@ -79,11 +113,38 @@ class BookingRepository extends BaseRepository {
|
|||
if(isset($data['company_service'])){
|
||||
$this->updateCompanyService($data['company_service']);
|
||||
}
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateCountryService($country_services){
|
||||
public function updateBookingNumber($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
$fill = [
|
||||
'ev_number' => $data['ev_number'],
|
||||
'merlin_order_number' => $data['merlin_order_number'],
|
||||
];
|
||||
$this->model->fill($fill);
|
||||
$this->model->save();
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateBookingPrice($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
$fill = [
|
||||
'deposit_total' => $data['deposit_total'] ? Util::_clean_float($data['deposit_total']) : 0,
|
||||
'final_payment' => $data['final_payment'] ? Util::_clean_float($data['final_payment']) : 0,
|
||||
'final_payment_date' => $data['final_payment_date'] ? _reformat_date($data['final_payment_date']) : null,
|
||||
];
|
||||
$this->model->fill($fill);
|
||||
$this->model->save();
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function updateCountryService($country_services){
|
||||
foreach ($country_services as $country_service_id=>$val){
|
||||
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $country_service_id)
|
||||
->where('booking_id', '=', $this->model->id)->first();
|
||||
|
|
@ -103,7 +164,7 @@ class BookingRepository extends BaseRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public function updateProviderService($provider_service){
|
||||
private function updateProviderService($provider_service){
|
||||
foreach ($provider_service as $provider_service_id=>$val){
|
||||
$booking_provider_service = BookingProviderService::where('service_provider_service_id', '=', $provider_service_id)
|
||||
->where('booking_id', '=', $this->model->id)->first();
|
||||
|
|
@ -123,7 +184,7 @@ class BookingRepository extends BaseRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public function updateCompanyService($company_service){
|
||||
private function updateCompanyService($company_service){
|
||||
foreach ($company_service as $company_service_id=>$val){
|
||||
$booking_company_service = BookingCompanyService::where('travel_company_service_id', '=', $company_service_id)
|
||||
->where('booking_id', '=', $this->model->id)->first();
|
||||
|
|
|
|||
|
|
@ -16,27 +16,13 @@ class CustomerRepository extends BaseRepository {
|
|||
|
||||
public function updateCustomer($id, $data)
|
||||
{
|
||||
|
||||
$this->model = Customer::findOrFail($id);
|
||||
$fill = [
|
||||
'salutation_id' => $data['salutation_id'],
|
||||
'name' => $data['name'],
|
||||
'firstname' => $data['firstname'],
|
||||
'street' => $data['street'],
|
||||
'zip' => $data['zip'],
|
||||
'city' => $data['city'],
|
||||
'email' => $data['email'],
|
||||
'phone' => $data['phone'],
|
||||
'phonemobile' => $data['phonemobile'],
|
||||
'country_id' => $data['country_id'],
|
||||
];
|
||||
$this->model->fill($fill);
|
||||
$this->model->fill($data);
|
||||
$this->model->save();
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
public function updateCustomerFromLead($id, $data){
|
||||
|
||||
$lead = Lead::findOrFail($id);
|
||||
|
|
|
|||
46
app/Services/Model.php
Normal file
46
app/Services/Model.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Status;
|
||||
use App\Models\SfGuardUser;
|
||||
use App\Models\Sym\TravelCountry as SymTravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelCategory;
|
||||
|
||||
class Model
|
||||
{
|
||||
|
||||
public static function getSfGuardUserArray(){
|
||||
return SfGuardUser::where('is_active', 1)->get()->pluck('fullname', 'id');
|
||||
}
|
||||
|
||||
public static function getTravelCountryArray($emtpy = false){
|
||||
$TravelCountry = TravelCountry::where('active_backend', 1)->orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelCountry->prepend('-', 0) : $TravelCountry;
|
||||
|
||||
}
|
||||
|
||||
public static function getTravelCategoryArray($emtpy = false){
|
||||
$TravelCategory = TravelCategory::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelCategory->prepend('-', 0) : $TravelCategory;
|
||||
|
||||
}
|
||||
|
||||
public static function getTravelAgendaArray($emtpy = false){
|
||||
$TravelAgenda = TravelAgenda::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelAgenda->prepend('-', 0) : $TravelAgenda;
|
||||
}
|
||||
|
||||
public static function getSymTravelCountryArray($emtpy = false){
|
||||
$TravelAgenda = SymTravelCountry::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelAgenda->prepend('-', 0) : $TravelAgenda;
|
||||
}
|
||||
|
||||
public static function getStatusArray($emtpy = false){
|
||||
$Status = Status::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $Status->prepend('-', 0) : $Status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue