Customer Mail, Mails, Views Lead Customer
This commit is contained in:
parent
f1e0900a7a
commit
f53f17f9c1
46 changed files with 2217 additions and 1489 deletions
86
app/Http/Controllers/CustomerController.php
Executable file
86
app/Http/Controllers/CustomerController.php
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Repositories\CustomerRepository;
|
||||
use Carbon;
|
||||
use Request;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
|
||||
protected $customerRepo;
|
||||
|
||||
public function __construct(CustomerRepository $customerRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerRepo = $customerRepo;
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'step' => $step
|
||||
];
|
||||
return view('customer.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$customer = new Customer();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$customer = Customer::findOrFail($id);
|
||||
$id = $customer->id;
|
||||
}
|
||||
$data = [
|
||||
'customer' => $customer,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('customer.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
return back();
|
||||
/* $data = Request::all();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
/*
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
}
|
||||
|
||||
public function getCustomers()
|
||||
{
|
||||
$query = Customer::with('salutation');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Customer $customer) {
|
||||
return '<a href="'.route('customer_detail', [$customer->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (Customer $customer) {
|
||||
return '<a data-order="'.$customer->id.'" href="'.route('customer_detail', [$customer->id]).'" data-id="'.$customer->id.'">'.$customer->id.'</a>';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'id'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
114
app/Http/Controllers/CustomerMailController.php
Executable file
114
app/Http/Controllers/CustomerMailController.php
Executable file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use Carbon;
|
||||
use Request;
|
||||
|
||||
class CustomerMailController extends Controller
|
||||
{
|
||||
|
||||
protected $customerMailRepo;
|
||||
|
||||
public function __construct(CustomerMailRepository $customerMailRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerMailRepo = $customerMailRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
];
|
||||
return view('customer.mail.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$customer_mail = new CustomerMail();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$customer_mail = CustomerMail::findOrFail($id);
|
||||
$id = $customer_mail->id;
|
||||
}
|
||||
$data = [
|
||||
'customer_mail' => $customer_mail,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('customer.mail.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
return back();
|
||||
/* $data = Request::all();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
/*
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
}
|
||||
|
||||
public function getCustomerMails()
|
||||
{
|
||||
$query = CustomerMail::with('booking')->with('customer');
|
||||
|
||||
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>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('booking_id', 'booking_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('booking_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'customer_id', 'booking_id', 'id'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
100
app/Http/Controllers/LeadController.php
Executable file
100
app/Http/Controllers/LeadController.php
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Lead;
|
||||
use App\Repositories\LeadRepository;
|
||||
use Carbon;
|
||||
use Request;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
|
||||
protected $leadRepo;
|
||||
|
||||
public function __construct(LeadRepository $leadRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->leadRepo = $leadRepo;
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'step' => $step
|
||||
];
|
||||
return view('lead.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$lead = new Lead();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$lead = Lead::findOrFail($id);
|
||||
$id = $lead->id;
|
||||
}
|
||||
$data = [
|
||||
'lead' => $lead,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('lead.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
return back();
|
||||
/* $data = Request::all();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
/*
|
||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||
return redirect(route('lead_detail', [$lead->id]));*/
|
||||
}
|
||||
|
||||
public function getLeads()
|
||||
{
|
||||
$query = Lead::with('customer')->with('sf_guard_user')->with('status');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Lead $lead) {
|
||||
return '<a href="'.route('lead_detail', [$lead->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (Lead $lead) {
|
||||
return '<a data-order="'.$lead->id.'" href="'.route('lead_detail', [$lead->id]).'" data-id="'.$lead->id.'">'.$lead->id.'</a>';
|
||||
})
|
||||
->addColumn('customer_id', function (Lead $lead) {
|
||||
return '<a data-order="'.$lead->customer_id.'" href="'.route('customer_detail', [$lead->customer_id]).'" data-id="'.$lead->customer_id.'">'.$lead->customer_id.'</a>';
|
||||
})
|
||||
->addColumn('request_date', function (Lead $lead) {
|
||||
return Carbon::parse($lead->request_date)->format(\Util::formatDateDB());
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('customer_id', 'customer_id $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.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,9 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Booking;
|
||||
use App\Models\Sym\TravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Request;
|
||||
use DataTables;
|
||||
|
||||
|
|
@ -21,7 +23,6 @@ class RequestController extends Controller
|
|||
public function index($step = false)
|
||||
{
|
||||
|
||||
|
||||
$d = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$data = [
|
||||
|
|
@ -31,6 +32,17 @@ class RequestController extends Controller
|
|||
return view('request.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
|
||||
$d = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$data = [
|
||||
'travel_countries' => $d,
|
||||
];
|
||||
return view('request.index', $data);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
wirte old where has state to new has travel_documents
|
||||
|
|
@ -70,7 +82,6 @@ class RequestController extends Controller
|
|||
}
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
|
||||
if(Request::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
||||
|
|
@ -146,8 +157,6 @@ class RequestController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Request::get('sort_travel_country_id') != ""){
|
||||
$query->where('travel_country_id', '=', Request::get('sort_travel_country_id'));
|
||||
}
|
||||
|
|
@ -172,6 +181,7 @@ class RequestController extends Controller
|
|||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getAjaxRequests(){
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
|
|
@ -179,14 +189,58 @@ class RequestController extends Controller
|
|||
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function loadModal(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()){
|
||||
|
||||
$customers = [];
|
||||
$query = $this->getSearchRequests();
|
||||
$bookings = $query->orderBy('id', 'DESC')->limit(50)->get();
|
||||
foreach ($bookings as $booking){
|
||||
$tmp = "";
|
||||
$tmp .= $booking->customer ? $booking->customer->email." | " : "- | ";
|
||||
$tmp .= $booking->customer ? $booking->customer->firstname." ".$booking->customer->name." | " : "- | ";
|
||||
$tmp .= $booking->travel_country_id ? $booking->travel_country->name." | " : "- | ";
|
||||
$tmp .= $booking->travelagenda_id ? $booking->travel_agenda->name."" : "-";
|
||||
|
||||
$customers[$booking->id] = $tmp;
|
||||
}
|
||||
|
||||
// return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
|
||||
if($data['action'] === "send-customer-mail"){
|
||||
$value = new Collection();
|
||||
$value->id = "add";
|
||||
$value->customers = $customers;
|
||||
$value->message = "Sehr #geehrte/r# #Anrede# #Vorname# #Nachname#,\n\nText ....";
|
||||
$data['title'] = "E-Mail-Nachricht an Auswahl";
|
||||
$url = route('requests_send_customer_mail');
|
||||
$ret = view("request.modal-mail", compact('data','value', 'url') )->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
public function sendCustomerMail(CustomerMailRepository $customerMailRepository){
|
||||
$data = Request::all();
|
||||
|
||||
$customerMailRepository->sendAndStore($data);
|
||||
\Session()->flash('alert-success', "Mails gesendet!");
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getRequests()
|
||||
{
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return ''; //'<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
->addColumn('action_lead_edit', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
|
||||
|
|
@ -200,6 +254,9 @@ class RequestController extends Controller
|
|||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('action_booking_edit', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('travel_country_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_country_id ? $booking->travel_country_id : 0).'">'.($booking->travel_country_id ? $booking->travel_country->name : "-").'</span>';
|
||||
})
|
||||
|
|
@ -245,11 +302,9 @@ class RequestController extends Controller
|
|||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_edit', 'lead_id', 'participant_firstname', 'participant_name', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
34
app/Mail/MailSendInfo.php
Normal file
34
app/Mail/MailSendInfo.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailSendInfo extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $travel_user_booking_fewo;
|
||||
public $subject;
|
||||
protected $content;
|
||||
|
||||
|
||||
public function __construct($subject, $content)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('emails.content')->with([
|
||||
'content' => $this->content,
|
||||
'greetings' => __('Best regards'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -11,13 +11,20 @@ use Reliese\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class CMSAuthor
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSAuthor whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CMSAuthor extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,39 +121,32 @@ class Customer extends Model
|
|||
'participants_remarks',
|
||||
'miscellaneous_remarks',
|
||||
'country_id',
|
||||
|
||||
];
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'country_id');
|
||||
}
|
||||
|
||||
public function credit_card_type()
|
||||
{
|
||||
return $this->belongsTo(CreditCardType::class);
|
||||
}
|
||||
|
||||
public function salutation()
|
||||
{
|
||||
return $this->belongsTo(Salutation::class);
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function coupons()
|
||||
{
|
||||
return $this->hasMany(Coupon::class);
|
||||
}
|
||||
|
||||
public function leads()
|
||||
{
|
||||
return $this->hasMany(Lead::class);
|
||||
}
|
||||
|
||||
public function fullName()
|
||||
{
|
||||
if ($this->firstname) {
|
||||
|
|
@ -161,7 +154,6 @@ class Customer extends Model
|
|||
}
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
109
app/Models/CustomerMail.php
Normal file
109
app/Models/CustomerMail.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Reliese\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomerMail
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $booking_id
|
||||
* @property int $customer_id
|
||||
* @property int $lead_id
|
||||
* @property string $subject
|
||||
* @property string $message
|
||||
* @property bool $send
|
||||
* @property bool $fail
|
||||
* @property string $error
|
||||
* @property Carbon $sent_at
|
||||
* @property Carbon $scheduled_at
|
||||
* @property Carbon $delivered_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Booking $booking
|
||||
* @property Customer $customer
|
||||
* @property Lead $lead
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereBookingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCustomerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereDeliveredAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereError($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereFail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereLeadId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereScheduledAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSend($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSentAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CustomerMail extends Model
|
||||
{
|
||||
protected $table = 'customer_mails';
|
||||
|
||||
protected $casts = [
|
||||
'booking_id' => 'int',
|
||||
'customer_id' => 'int',
|
||||
'lead_id' => 'int',
|
||||
'send' => 'bool',
|
||||
'fail' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'booking_id',
|
||||
'customer_id',
|
||||
'lead_id',
|
||||
'email',
|
||||
'subject',
|
||||
'message',
|
||||
'send',
|
||||
'fail',
|
||||
'error',
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function getSentAtAttribute(){
|
||||
if(!$this->attributes['sent_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute(){
|
||||
if(!$this->attributes['created_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
}
|
||||
|
|
@ -11,13 +11,20 @@ use Reliese\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class Keyword
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Keyword whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Keyword extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereBoxImageUrl($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereCountryId($value)
|
||||
* @property-read int|null $iq_content_sites_count
|
||||
* @property int|null $author_id
|
||||
* @property-read \App\Models\CMSAuthor|null $author
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelGuide whereAuthorId($value)
|
||||
*/
|
||||
class TravelGuide extends Model
|
||||
{
|
||||
|
|
@ -98,7 +101,7 @@ class TravelGuide extends Model
|
|||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Author', 'author_id', 'id');
|
||||
return $this->belongsTo('App\Models\CMSAuthor', 'author_id', 'id');
|
||||
}
|
||||
|
||||
public static function getScopeOptions($setKey = false){
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram query()
|
||||
* @property-read int|null $classes_count
|
||||
* @property-read int|null $travel_program_drafts_count
|
||||
* @property string|null $keywords
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereKeywords($value)
|
||||
*/
|
||||
class TravelProgram extends Model
|
||||
{
|
||||
|
|
|
|||
89
app/Repositories/CustomerMailRepository.php
Normal file
89
app/Repositories/CustomerMailRepository.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
|
||||
use App\Mail\MailSendFeWoService;
|
||||
use App\Mail\MailSendInfo;
|
||||
use App\Models\Booking;
|
||||
use App\Models\CustomerMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class CustomerMailRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(CustomerMail $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function sendAndStore($data){
|
||||
if(isset($data['send_mail_to']) && is_array($data['send_mail_to'])) {
|
||||
foreach ($data['send_mail_to'] as $booking_id => $on) {
|
||||
$booking = Booking::find($booking_id);
|
||||
if ($booking->customer) {
|
||||
$message = $this->prepareContent($booking, $data['message']);
|
||||
$subject = $this->prepareContent($booking, $data['subject']);
|
||||
$customer_mail = $this->store($booking, $subject, $message);
|
||||
$this->sendMail($customer_mail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function store($booking, $subject, $message){
|
||||
|
||||
$customer_mail = CustomerMail::create([
|
||||
'booking_id' => $booking->id,
|
||||
'customer_id' => $booking->customer_id,
|
||||
'lead_id' => $booking->lead_id,
|
||||
'email' => $booking->customer->email,
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
|
||||
]);
|
||||
return $customer_mail;
|
||||
}
|
||||
|
||||
private function sendMail($customer_mail){
|
||||
|
||||
try{
|
||||
Mail::to($customer_mail->email)->send(new MailSendInfo($customer_mail->subject, $customer_mail->message));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
return false;
|
||||
}
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
return true;
|
||||
}
|
||||
private function prepareContent($booking, $content){
|
||||
|
||||
$first_name = $booking->customer->firstname;
|
||||
$last_name = $booking->customer->name;
|
||||
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
|
||||
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
|
||||
$salutation = $booking->customer->salutation->name;
|
||||
|
||||
|
||||
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
|
||||
$search = ['#geehrte/r#', '#Anrede#', '#Vorname#', '#Nachname#', '#Reiseland#', '#Programm#'];
|
||||
$replace = [$dear, $salutation, $first_name, $last_name, $country, $program, $salutation];
|
||||
$content = str_replace($search, $replace, $content);
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
21
app/Repositories/CustomerRepository.php
Normal file
21
app/Repositories/CustomerRepository.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
|
||||
use App\Models\Booking;
|
||||
|
||||
class CustomerRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(Booking $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
}
|
||||
21
app/Repositories/LeadRepository.php
Normal file
21
app/Repositories/LeadRepository.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
|
||||
use App\Models\Booking;
|
||||
|
||||
class LeadRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(Booking $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue