First Commit
This commit is contained in:
commit
0c9a118281
633 changed files with 76612 additions and 0 deletions
42
app/Console/Kernel.php
Executable file
42
app/Console/Kernel.php
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
51
app/Exceptions/Handler.php
Executable file
51
app/Exceptions/Handler.php
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
45
app/Http/Controllers/API/DraftController.php
Executable file
45
app/Http/Controllers/API/DraftController.php
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Draft;
|
||||
use App\Models\TravelProgram;
|
||||
use HTMLHelper;
|
||||
|
||||
|
||||
class DraftController extends Controller
|
||||
{
|
||||
public $successStatus = 200;
|
||||
|
||||
|
||||
public function draft($action)
|
||||
{
|
||||
if($action == "get_draft_list"){
|
||||
$drafts = Draft::where('active', true)->get()->sortByDesc("id");
|
||||
return response()->json(['success' => $drafts], $this->successStatus);
|
||||
}
|
||||
|
||||
if($action == "get_draft_list_for_table"){
|
||||
$ret = [];
|
||||
if(request('program_id') && request('program_id') > 0){
|
||||
$travel_program = TravelProgram::find(request('program_id'));
|
||||
if(count($travel_program->travel_program_drafts)){
|
||||
foreach ($travel_program->travel_program_drafts as $travel_program_draft){
|
||||
$key = $travel_program_draft->id;
|
||||
$ret[$key]['name'] = $travel_program_draft->draft->name;
|
||||
if($travel_program_draft->travel_class){
|
||||
$ret[$key]['travel_class'] = $travel_program_draft->travel_class->name;
|
||||
}else{
|
||||
$ret[$key]['travel_class'] = "alle Kategorien";
|
||||
}
|
||||
$ret[$key]['weekdays'] = HTMLHelper::getWeekdaysString($travel_program_draft->weekdays);
|
||||
}
|
||||
}
|
||||
}
|
||||
return response()->json(['success' => $ret], $this->successStatus);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
79
app/Http/Controllers/API/UserController.php
Executable file
79
app/Http/Controllers/API/UserController.php
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Validator;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public $successStatus = 200;
|
||||
|
||||
/**
|
||||
* login api
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if (Auth::attempt(['email' => request('email'), 'password' => request('password')])) {
|
||||
$user = Auth::user();
|
||||
if(!$user->isSuperAdmin()) {
|
||||
return response()->json(['error' => 'Unauthorised'], 401);
|
||||
}
|
||||
$success['token'] = $user->createToken('SternToursCRM')->accessToken;
|
||||
return response()->json(['success' => $success], $this->successStatus);
|
||||
} else {
|
||||
return response()->json(['error' => 'Unauthorised'], 401);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register api
|
||||
* api.mein.sterntours.de
|
||||
* 6m9j,v2GE8px<bt75w
|
||||
* info@mein.sterntours.de
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
/*public function register(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
'c_password' => 'required|same:password',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['error' => $validator->errors()], 401);
|
||||
}
|
||||
$input = $request->all();
|
||||
$input['password'] = bcrypt($input['password']);
|
||||
$user = User::create($input);
|
||||
$success['token'] = $user->createToken('SternToursCRM')->accessToken;
|
||||
$success['name'] = $user->name;
|
||||
return response()->json(['success' => $success], $this->successStatus);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* details api
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$user = Auth::user();
|
||||
return response()->json(['success' => $user], $this->successStatus);
|
||||
}
|
||||
|
||||
public function draft($action)
|
||||
{
|
||||
|
||||
$user = Auth::user();
|
||||
return response()->json(['success' => $user], $this->successStatus);
|
||||
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/AdminUserController.php
Executable file
85
app/Http/Controllers/AdminUserController.php
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class AdminUserController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('superadmin');
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
//'values' => User::where('admin', 0)->get(),
|
||||
'values' => User::where('confirmation_code_remider', '!=', 2)->get(),
|
||||
];
|
||||
return view('admin.users', $data);
|
||||
}
|
||||
|
||||
public function edit($user_id)
|
||||
{
|
||||
$user = User::findOrFail($user_id);
|
||||
/*if(!$user->account){
|
||||
$user->account = new Account();
|
||||
}
|
||||
*/
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('admin.user_edit', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = Input::all();
|
||||
$user = User::findOrFail($data['id']);
|
||||
|
||||
$user->admin = $data['admin'];
|
||||
$user->confirmed = isset($data['confirmed']) ? true : false;
|
||||
$user->active = isset($data['active']) ? true : false;
|
||||
$user->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/admin/users');
|
||||
|
||||
}
|
||||
|
||||
public function deleteUser($user_id)
|
||||
{
|
||||
$user = User::findOrFail($user_id);
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
\Session()->flash('alert-success', "Kontakt gelöscht");
|
||||
return redirect('/admin/users');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
69
app/Http/Controllers/Auth/LoginController.php
Executable file
69
app/Http/Controllers/Auth/LoginController.php
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
|
||||
protected function authenticated(Request $request, $user)
|
||||
{
|
||||
$user->last_login = date('Y-m-d H:i:s');
|
||||
$user->save();
|
||||
}
|
||||
protected function handleUserWasAuthenticated(Request $request, $throttles)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*
|
||||
//
|
||||
/* protected function validateLogin(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
$this->username() => 'required|exists:users,' . $this->username() . ',active,1',
|
||||
'password' => 'required',
|
||||
], [
|
||||
$this->username() . '.exists' => trans('validation.usernotactive'),
|
||||
]);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
80
app/Http/Controllers/Auth/RegisterController.php
Executable file
80
app/Http/Controllers/Auth/RegisterController.php
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
//register off! - to login
|
||||
return redirect('login');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Executable file
13
app/Http/Controllers/Controller.php
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
67
app/Http/Controllers/CronController.php
Normal file
67
app/Http/Controllers/CronController.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->checkConfirmation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
//delete user
|
||||
if ($user->confirmation_code_remider == 1) {
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
}
|
||||
//send new remider
|
||||
if ($user->confirmation_code_remider == 0) {
|
||||
Mail::to($user->email)->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
76
app/Http/Controllers/DataTableController.php
Normal file
76
app/Http/Controllers/DataTableController.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\HTMLHelper;
|
||||
use DataTables;
|
||||
use App\User;
|
||||
|
||||
class DataTableController extends Controller
|
||||
{
|
||||
public function datatable()
|
||||
{
|
||||
return view('datatable');
|
||||
}
|
||||
|
||||
/*public function getLeads()
|
||||
{
|
||||
|
||||
$query = User::where('deleted_at', '=', null);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('first_name', function (User $user) {
|
||||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('action', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->rawColumns(['action', 'confirmed', 'active'])
|
||||
->make(true);
|
||||
}*/
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
//confirmation_code_remider is delete 2
|
||||
$query = User::where('deleted_at', '=', null);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (User $user) {
|
||||
return '<a href="' . route('admin_user_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('admin', function (User $user) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-default" data-id="'.$user->id.'" data-email="'.$user->email.'" data-admin="'.$user->admin.'" data-active="'.$user->active.'" data-confirmed="'.$user->confirmed.'">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('action_delete', function (User $user) {
|
||||
return '<a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('admin', 'active $1')
|
||||
->rawColumns(['action_edit', 'admin', 'confirmed', 'active', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**/
|
||||
289
app/Http/Controllers/DraftController.php
Executable file
289
app/Http/Controllers/DraftController.php
Executable file
|
|
@ -0,0 +1,289 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Draft;
|
||||
use App\Models\DraftItem;
|
||||
use App\Models\DraftType;
|
||||
use Input;
|
||||
|
||||
class DraftController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'drafts' => Draft::all()->sortByDesc("id"),
|
||||
'draft_types' => DraftType::all()->sortByDesc("id"),
|
||||
'step' => $step
|
||||
];
|
||||
return view('drafts.index', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
$draft = new Draft();
|
||||
$draft->active = true;
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$draft = Draft::findOrFail($id);
|
||||
$id = $draft->id;
|
||||
}
|
||||
$data = [
|
||||
'draft' => $draft,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('drafts.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Input::all();
|
||||
if($id == "new") {
|
||||
$draft = new Draft();
|
||||
}else{
|
||||
$draft = Draft::findOrFail($id);
|
||||
}
|
||||
|
||||
$draft->name = $data['name'];
|
||||
$draft->active = isset($data['active']) ? true : false;
|
||||
$draft->save();
|
||||
|
||||
$i = 1;
|
||||
if(isset($data['draft_item'])){
|
||||
foreach ($data['draft_item'] as $draft_item_id => $draft_item){
|
||||
if($data['action'] == 'saveAllFromOld'){
|
||||
$di = $draft->draft_items()->create([]);
|
||||
}else{
|
||||
$di = DraftItem::findOrFail($draft_item_id);
|
||||
}
|
||||
$di->draft_type_id = $draft_item['draft_type_id'];
|
||||
$di->days_start = $draft_item['days_start'];
|
||||
$di->days_duration = $draft_item['days_duration'];
|
||||
$di->service = $draft_item['service'];
|
||||
$di->price_adult = $draft_item['price_adult'];
|
||||
$di->adult = $draft_item['adult'];
|
||||
$di->price_children = $draft_item['price_children'];
|
||||
$di->children = $draft_item['children'];
|
||||
$di->in_pdf = isset($draft_item['in_pdf']) ? true : false;
|
||||
$di->pos = $i++;
|
||||
|
||||
$di->save();
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'addItem'){
|
||||
$draft->draft_items()->create(['pos' => $i]);
|
||||
}
|
||||
if(strpos($data['action'], 'up_') !== false) {
|
||||
$reId = intval(str_replace('up_', '', $data['action']));
|
||||
$d_from = DraftItem::findOrFail($reId);
|
||||
$d_to = $draft->findBeforeRelation($reId);
|
||||
if($d_to) {
|
||||
$t_pos = $d_from->pos;
|
||||
$d_from->pos = $d_to->pos;
|
||||
$d_to->pos = $t_pos;
|
||||
$d_from->save();
|
||||
$d_to->save();
|
||||
}
|
||||
}
|
||||
if(strpos($data['action'], 'down_') !== false) {
|
||||
$reId = intval(str_replace('down_', '', $data['action']));
|
||||
$d_from = DraftItem::findOrFail($reId);
|
||||
$d_to = $draft->findAfterRelation($reId);
|
||||
if($d_to) {
|
||||
$t_pos = $d_from->pos;
|
||||
$d_from->pos = $d_to->pos;
|
||||
$d_to->pos = $t_pos;
|
||||
$d_from->save();
|
||||
$d_to->save();
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('draft_detail', [$draft->id]));
|
||||
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$draft = Draft::findOrFail($id);
|
||||
|
||||
foreach ($draft->draft_items as $draft_item){
|
||||
$draft_item->delete();
|
||||
}
|
||||
$draft->delete();
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('drafts'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function itemDelete($id){
|
||||
$draft_item = DraftItem::findOrFail($id);
|
||||
$draft_id = $draft_item->draft_id;
|
||||
$draft_item->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('draft_detail', [$draft_id]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function typeUpdate(){
|
||||
|
||||
$data = Input::all();
|
||||
if($data['id'] == "new"){
|
||||
$draft_type = DraftType::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$draft_type = DraftType::find($data['id']);
|
||||
$draft_type->name = $data['name'];
|
||||
$draft_type->active = isset($data['active']) ? true : false;
|
||||
$draft_type->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('drafts', ['type']));
|
||||
|
||||
}
|
||||
public function typeDelete($id){
|
||||
|
||||
if(DraftItem::where('draft_type_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird verwendet');
|
||||
return redirect(route('drafts'));
|
||||
}
|
||||
$draft_type = DraftType::findOrFail($id);
|
||||
$draft_type->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('drafts', ['type']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function loadOldAction(){
|
||||
$data = Input::all();
|
||||
$template = \App\Models\Sym\ArrangementTemplate::findOrFail($data['load_old']);
|
||||
|
||||
$draft = new Draft();
|
||||
$draft->active = true;
|
||||
$draft->name = $template->title;
|
||||
|
||||
$draft_items = [];
|
||||
foreach ($template->arrangements as $arrangement){
|
||||
$data_s = explode("\n", $arrangement->data_s);
|
||||
$service = "";
|
||||
$priceAdult = false;
|
||||
$adult = false;
|
||||
$priceChildren = false;
|
||||
$children = false;
|
||||
|
||||
foreach ($data_s as $ds){
|
||||
if(strpos($ds, 'Name:') !== false){
|
||||
$service .= str_replace('Name: ', '', $ds);
|
||||
$ds = "";
|
||||
}
|
||||
if(strpos($ds, 'Preis:') !== false){
|
||||
$p = floatval(str_replace('Preis: ', '', $ds));
|
||||
$priceAdult = number_format($p, 2, ',', '.');
|
||||
$ds = "";
|
||||
}
|
||||
if(strpos($ds, 'Teilnehmer:') !== false){
|
||||
$adult = intval(str_replace('Teilnehmer: ', '', $ds));
|
||||
$ds = "";
|
||||
}
|
||||
if(strpos($ds, 'KindPreis:') !== false){
|
||||
$p = floatval(str_replace('KindPreis: ', '', $ds));
|
||||
$priceChildren = number_format($p, 2, ',', '.');
|
||||
$ds = "";
|
||||
}
|
||||
if(strpos($ds, 'Kind:') !== false){
|
||||
$children = intval(str_replace('Kind: ', '', $ds));
|
||||
$ds = "";
|
||||
}
|
||||
if($ds != ""){
|
||||
$service .= $ds;
|
||||
}
|
||||
}
|
||||
$draft_items[] = array(
|
||||
'draft_type_id' => $arrangement->type_id,
|
||||
'in_pdf' => $arrangement->in_pdf,
|
||||
'service' => trim($service),
|
||||
'price_adult' => $priceAdult,
|
||||
'adult' => $adult,
|
||||
'price_children' => $priceChildren,
|
||||
'children' => $children,
|
||||
'days_start' => null,
|
||||
'days_duration' => null,
|
||||
);
|
||||
}
|
||||
$data = [
|
||||
'draft' => $draft,
|
||||
'draft_items' => $draft_items,
|
||||
'id' => 'new',
|
||||
];
|
||||
return view('drafts.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function loadNew(){
|
||||
$data = [
|
||||
'drafts' => Draft::all()->sortByDesc("id"),
|
||||
];
|
||||
return view('drafts.load_new', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function loadNewAction(){
|
||||
$data = Input::all();
|
||||
$d = Draft::findOrFail($data['load_new']);
|
||||
$draft = new Draft();
|
||||
$draft->active = true;
|
||||
$draft->name = $d->name;
|
||||
|
||||
$draft_items = [];
|
||||
foreach ($d->draft_items as $di){
|
||||
$draft_items[] = array(
|
||||
'draft_type_id' => $di->draft_type_id,
|
||||
'in_pdf' => $di->in_pdf,
|
||||
'service' => $di->service,
|
||||
'price_adult' => $di->price_adult,
|
||||
'adult' => $di->adult,
|
||||
'price_children' => $di->price_children,
|
||||
'children' => $di->children,
|
||||
'days_start' => $di->days_start,
|
||||
'days_duration' => $di->days_duration,
|
||||
);
|
||||
}
|
||||
$data = [
|
||||
'draft' => $draft,
|
||||
'draft_items' => $draft_items,
|
||||
'id' => 'new',
|
||||
];
|
||||
return view('drafts.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function loadOld(){
|
||||
$data = [
|
||||
'templates' => \App\Models\Sym\ArrangementTemplate::all(),
|
||||
];
|
||||
return view('drafts.load_old', $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
120
app/Http/Controllers/HomeController.php
Executable file
120
app/Http/Controllers/HomeController.php
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\SfGuardUser;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use Request;
|
||||
use Input;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
return redirect('home');
|
||||
|
||||
}
|
||||
|
||||
//login
|
||||
public function show()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
];
|
||||
return view('home', $data);
|
||||
}
|
||||
|
||||
|
||||
public function loadingModal(){
|
||||
|
||||
$data = Input::get('data');
|
||||
$target = Input::get('target');
|
||||
|
||||
$response = "";
|
||||
if($data == "data_protection"){
|
||||
$response = view('legal.data_protect_de')->render();
|
||||
}
|
||||
if($data == "imprint"){
|
||||
$response = view('legal.imprint_de')->render();
|
||||
}
|
||||
if(Request::ajax()) {
|
||||
return response()->json(['response' => $response, 'target'=>$target]);
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function checkLogin($identify, $token)
|
||||
{
|
||||
if($identify){
|
||||
//user find by $identify
|
||||
$user = User::where('identify', '=', $identify)->first();
|
||||
if(!$user){
|
||||
return abort(404);
|
||||
}
|
||||
//user - check für from $sf_guard_user - old system
|
||||
$sf_guard_user = SfGuardUser::where('identify', '=', $identify)->first();
|
||||
if(!$sf_guard_user){
|
||||
return abort(404);
|
||||
}
|
||||
if($user->id != $sf_guard_user->user_id){
|
||||
return abort(404);
|
||||
|
||||
}
|
||||
if($sf_guard_user->token != $token){
|
||||
return abort(404);
|
||||
}
|
||||
$time = Carbon::parse($sf_guard_user->token_at);
|
||||
$now = Carbon::now();
|
||||
$duration = $time->diffInSeconds($now);
|
||||
|
||||
if($duration > 3){
|
||||
return abort(404);
|
||||
}
|
||||
$sf_guard_user->token = null;
|
||||
$sf_guard_user->token_at = null;
|
||||
$sf_guard_user->save();
|
||||
if(!Auth::check()){
|
||||
$user->last_login = now();
|
||||
$user->save();
|
||||
Auth::login($user);
|
||||
}
|
||||
if(Auth::check()){
|
||||
return redirect(route('drafts'));
|
||||
}
|
||||
}
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
public function legalDataProtected()
|
||||
{
|
||||
return view('legal.data_protected');
|
||||
}
|
||||
|
||||
public function legalImprint()
|
||||
{
|
||||
return view('legal.imprint');
|
||||
}
|
||||
}
|
||||
179
app/Http/Controllers/TranslationController.php
Executable file
179
app/Http/Controllers/TranslationController.php
Executable file
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use File;
|
||||
use Input;
|
||||
|
||||
class TranslationController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $languagesPath;
|
||||
protected $directory_separator;
|
||||
protected $from;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
$this->languagesPath = App::langPath();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return redirect('admin/translate/edit/de');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $language
|
||||
* @param string $from
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function edit($language, $from = 'en')
|
||||
{
|
||||
$localisations = array_keys(config('localization.supportedLocales'));
|
||||
$files = $this->json_files($localisations);
|
||||
$translations = $this->translationsJson($language, $from);
|
||||
$show = "all";
|
||||
return view('translation.index', compact('files','translations', 'language', 'from', 'show'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $lang
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function update($language)
|
||||
{
|
||||
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$file = $path.$language.".json";
|
||||
$data = Input::all();
|
||||
$this->backup($path, $language.".json");
|
||||
unset($data['_token']);
|
||||
|
||||
$ret = [];
|
||||
//file make keys
|
||||
$source = json_decode(File::get($path."de.json"));
|
||||
foreach ($source as $key => $v){
|
||||
$skey = $this->sanitize($key);
|
||||
if(!empty($data[$skey])) {
|
||||
$ret[$key] = $data[$skey];
|
||||
}
|
||||
}
|
||||
$jsonData = json_encode($ret, TRUE);
|
||||
file_put_contents($file, $jsonData);
|
||||
return redirect()
|
||||
->route('admin_translate_edit', [$language])
|
||||
->with('message', 'Translation added successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $langs
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function json_files($localisations){
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$content = array();
|
||||
foreach ($localisations as $local){
|
||||
$file = File::get($path.$local.".json");
|
||||
if($file){
|
||||
$content[$local] = array('path'=>$path.$local.".json", 'content'=>json_encode($file));
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $language
|
||||
* @param $from
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function translationsJson($language, $from)
|
||||
{
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$file = array();
|
||||
$file['keys'] = (array) json_decode(File::get($path."de.json"));
|
||||
$file['keys'] = $this->sanitizeKey($file['keys']);
|
||||
$file['from'] = (array) json_decode(File::get($path.$from.".json"));
|
||||
$file['from'] = $this->sanitizeKey($file['from']);
|
||||
$file['dest'] = (array) json_decode(File::get($path.$language.".json"));
|
||||
$file['dest'] = $this->sanitizeKey($file['dest']);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function backup($path, $file)
|
||||
{
|
||||
|
||||
if (!File::exists(storage_path('language/'))) {
|
||||
File::makeDirectory(storage_path('language/'), 0755, true);
|
||||
}
|
||||
|
||||
return File::copy($path.$file, storage_path('language/'.time()."-".$file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
protected function resourcePath($path)
|
||||
{
|
||||
return "{$path}{$this->directory_separator}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $arr
|
||||
* @return mixed
|
||||
*/
|
||||
protected function sanitizeKey($arr){
|
||||
foreach ($arr as $key => $val){
|
||||
unset($arr[$key]);
|
||||
$arr[$this->sanitize($key)] = $val;
|
||||
}
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @param bool $force_lowercase
|
||||
* @param bool $anal
|
||||
* @return mixed|null|string|string[]
|
||||
*/
|
||||
protected function sanitize($string, $force_lowercase = true, $anal = false)
|
||||
{
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
|
||||
"—", "–", ",", "<", ".", ">", "/", "?");
|
||||
$clean = trim(str_replace($strip, "", strip_tags($string)));
|
||||
$clean = preg_replace('/\s+/', "_", $clean);
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
|
||||
return ($force_lowercase) ?
|
||||
(function_exists('mb_strtolower')) ?
|
||||
mb_strtolower($clean, 'UTF-8') :
|
||||
strtolower($clean) :
|
||||
$clean;
|
||||
}
|
||||
|
||||
}
|
||||
107
app/Http/Controllers/TravelProgramController.php
Executable file
107
app/Http/Controllers/TravelProgramController.php
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\TravelClass;
|
||||
use App\Models\TravelProgram;
|
||||
use App\Models\TravelProgramDraft;
|
||||
use App\Repositories\TravelProgramRepository;
|
||||
use Input;
|
||||
|
||||
class TravelProgramController extends Controller
|
||||
{
|
||||
|
||||
protected $travelProgramRepo;
|
||||
|
||||
public function __construct(TravelProgramRepository $travelProgramRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->travelProgramRepo = $travelProgramRepo;
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'travel_programs' => TravelProgram::all()->sortByDesc("id"),
|
||||
'step' => $step
|
||||
];
|
||||
return view('travel.program.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
$program = new TravelProgram();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$program = TravelProgram::findOrFail($id);
|
||||
$id = $program->id;
|
||||
}
|
||||
$data = [
|
||||
'program' => $program,
|
||||
'id' => $id,
|
||||
];
|
||||
return view('travel.program.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id)
|
||||
{
|
||||
$data = Input::all();
|
||||
$program = $this->travelProgramRepo->update($data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_program_detail', [$program->id]));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* PROGRAM CLASSES
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function classUpdate(){
|
||||
$data = Input::all();
|
||||
$this->travelProgramRepo->updateClass($data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_program_detail', [$data['program_id']]));
|
||||
}
|
||||
public function classDelete($id){
|
||||
$travel_class = TravelClass::findOrFail($id);
|
||||
$pId = $travel_class->program_id;
|
||||
if(count($travel_class->travel_program_drafts)){
|
||||
\Session()->flash('alert-error', 'Eintrag wird bei den Vorlagen verwendet');
|
||||
return redirect(route('travel_program_detail', [$pId]));
|
||||
}
|
||||
$travel_class->delete();
|
||||
\Session()->flash('alert-success', 'Programm Kategorie gelöscht');
|
||||
return redirect(route('travel_program_detail', [$pId]));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* PROGRAM DRAFTS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function draftUpdate(){
|
||||
$data = Input::all();
|
||||
$this->travelProgramRepo->updateDraft($data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('travel_program_detail', [$data['travel_program_id']]));
|
||||
}
|
||||
public function draftDelete($id){
|
||||
$travel_program_draft = TravelProgramDraft::findOrFail($id);
|
||||
$pId = $travel_program_draft->travel_program_id;
|
||||
$travel_program_draft->delete();
|
||||
\Session()->flash('alert-success', 'Programm Vorlage gelöscht');
|
||||
return redirect(route('travel_program_detail', [$pId]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
96
app/Http/Controllers/UserDataController.php
Executable file
96
app/Http/Controllers/UserDataController.php
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use App\Repositories\UserRepository;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
|
||||
class UserDataController extends Controller
|
||||
{
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function userEdit(){
|
||||
$user = Auth::user();
|
||||
|
||||
/*if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}*/
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('user.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function userEditStore(){
|
||||
|
||||
$user = Auth::user();
|
||||
/*if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}*/
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'last_name' => 'required|max:255',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
if(Input::get('company') == 1){
|
||||
$rules['company_name'] = 'required|max:255';
|
||||
$rules['company_country_id'] = 'required|integer|min:1';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.edit', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$this->userRepo->update(Input::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/user/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function userDataAcceptedForm(){
|
||||
$user = Auth::user();
|
||||
|
||||
if(Input::get('sender_accepted_infos') == "on"){
|
||||
$user->agreement = now();
|
||||
}else {
|
||||
$user->agreement = null;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
}
|
||||
73
app/Http/Controllers/UserDeleteController.php
Executable file
73
app/Http/Controllers/UserDeleteController.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Repositories\UserRepository;
|
||||
|
||||
|
||||
|
||||
class UserDeleteController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
* @param UserRepository $userRepo
|
||||
*/
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function deleteAccount(){
|
||||
return view('user.delete_account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function deleteAccountAction(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$rules = array(
|
||||
'old_password' => 'required|old_password:' . Auth::user()->password,
|
||||
);
|
||||
|
||||
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
return Hash::check($value, current($parameters));
|
||||
|
||||
});
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.delete_account')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$this->userRepo->deleteUser($user);
|
||||
//make delete
|
||||
Auth::logout();
|
||||
\Session()->flash('alert-danger', __('account deleted'));
|
||||
return redirect(route('home'));
|
||||
}
|
||||
}
|
||||
}
|
||||
214
app/Http/Controllers/UserUpdateEmailController.php
Executable file
214
app/Http/Controllers/UserUpdateEmailController.php
Executable file
|
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailActivateUser;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class UserUpdateEmailController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $db;
|
||||
|
||||
protected $table = 'user_update_emails';
|
||||
|
||||
protected $resendAfter = 60; //1min
|
||||
|
||||
|
||||
public function __construct(Connection $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('user.update_email');
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . Auth::user()->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
$messages = $validator->messages();
|
||||
|
||||
return view('user.update_email')->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$this->sendActivationMail($user, $request->all());
|
||||
\Session()->flash('alert-success', __('We sent you an activation code. Check your email!'));
|
||||
return redirect(route('user_update_email'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* public function adminChangeMail($user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'user' => User::findOrFail($user_id),
|
||||
];
|
||||
return view('admin.change_email', $data);
|
||||
|
||||
}
|
||||
public function adminUpdateMail(Request $request, $user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($user_id);
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . $user->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
$messages = $validator->messages();
|
||||
|
||||
return view('admin.change_email', $data)->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$this->sendActivationMail($user, $request->all());
|
||||
\Session()->flash('alert-success', __('An activation code was sent to the account by e-mail!'));
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function activateMail($token)
|
||||
{
|
||||
|
||||
if ($updateEmail = $this->getUpdateEmailByToken($token)) {
|
||||
$user = User::findOrFail($updateEmail->user_id);
|
||||
if($user->id == $updateEmail->user_id){
|
||||
$user->fill([
|
||||
'email' => $updateEmail->email
|
||||
])->save();
|
||||
$this->deleteUpdateEmail($token);
|
||||
//Login!
|
||||
Auth::login($user);
|
||||
\Session()->flash('alert-success', __('Your e-mail has been changed.'));
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
return redirect('/home');
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
public function sendActivationMail($user, array $data)
|
||||
{
|
||||
$token = $this->createActivation($user, $data);
|
||||
Mail::to($data['email'])->send(new MailActivateUser($token, $user));
|
||||
}
|
||||
|
||||
|
||||
protected function getToken()
|
||||
{
|
||||
return hash_hmac('sha256', str_random(40), config('app.key'));
|
||||
}
|
||||
|
||||
public function createActivation($user, array $data)
|
||||
{
|
||||
|
||||
$updateEmail = $this->getUpdateEmail($user);
|
||||
|
||||
if (!$updateEmail) {
|
||||
return $this->createToken($user, $data);
|
||||
}
|
||||
return $this->regenerateToken($user, $data);
|
||||
|
||||
}
|
||||
|
||||
private function regenerateToken($user, array $data)
|
||||
{
|
||||
|
||||
$token = $this->getToken();
|
||||
$this->db->table($this->table)->where('user_id', $user->id)->update([
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
]);
|
||||
return $token;
|
||||
}
|
||||
|
||||
private function createToken($user, array $data)
|
||||
{
|
||||
$token = $this->getToken();
|
||||
$this->db->table($this->table)->insert([
|
||||
'user_id' => $user->id,
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
]);
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function getUpdateEmail($user)
|
||||
{
|
||||
return $this->db->table($this->table)->where('user_id', $user->id)->first();
|
||||
}
|
||||
|
||||
|
||||
public function getUpdateEmailByToken($token)
|
||||
{
|
||||
return $this->db->table($this->table)->where('token', $token)->first();
|
||||
}
|
||||
|
||||
public function deleteUpdateEmail($token)
|
||||
{
|
||||
$this->db->table($this->table)->where('token', $token)->delete();
|
||||
}
|
||||
}
|
||||
112
app/Http/Controllers/UserUpdatePasswordController.php
Executable file
112
app/Http/Controllers/UserUpdatePasswordController.php
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UserUpdatePasswordController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePassword()
|
||||
{
|
||||
return view('user.update_password');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePasswordStore(Request $request)
|
||||
{
|
||||
$rules = array(
|
||||
'old_password' => 'required|old_password:' . Auth::user()->password,
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
);
|
||||
|
||||
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
return Hash::check($value, current($parameters));
|
||||
|
||||
});
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$request->user()->fill([
|
||||
'password' => Hash::make($request->password)
|
||||
])->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('user_update_password'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePasswordFirst(){
|
||||
if(!Auth::user()->isPasswort()){
|
||||
return view('user.update_password_first');
|
||||
}
|
||||
return redirect(route('user_update_password'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Update the password for the user.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function updatePasswordFirstStore(Request $request)
|
||||
{
|
||||
$rules = array(
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
);
|
||||
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password_first')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$request->user()->fill([
|
||||
'password' => Hash::make($request->password)
|
||||
])->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect('/home');
|
||||
}
|
||||
}
|
||||
66
app/Http/Kernel.php
Executable file
66
app/Http/Kernel.php
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
//\App\Http\Middleware\Localization::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'admin' => \App\Http\Middleware\Admin::class,
|
||||
'superadmin' => \App\Http\Middleware\SuperAdmin::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
];
|
||||
}
|
||||
26
app/Http/Middleware/Admin.php
Executable file
26
app/Http/Middleware/Admin.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class Admin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ( Auth::check() && Auth::user()->isAdmin() )
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Executable file
17
app/Http/Middleware/EncryptCookies.php
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
30
app/Http/Middleware/Localization.php
Executable file
30
app/Http/Middleware/Localization.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class Localization
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if ( \Session::has('locale')) {
|
||||
\App::setLocale(\Session::get('locale'));
|
||||
// You also can set the Carbon locale
|
||||
//Carbon::setLocale(\Session::get('locale'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
26
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
26
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
26
app/Http/Middleware/SuperAdmin.php
Executable file
26
app/Http/Middleware/SuperAdmin.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class SuperAdmin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ( Auth::check() && Auth::user()->isSuperAdmin() )
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
18
app/Http/Middleware/TrimStrings.php
Executable file
18
app/Http/Middleware/TrimStrings.php
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
23
app/Http/Middleware/TrustProxies.php
Executable file
23
app/Http/Middleware/TrustProxies.php
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Executable file
17
app/Http/Middleware/VerifyCsrfToken.php
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
53
app/Mail/MailActivateUser.php
Normal file
53
app/Mail/MailActivateUser.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailActivateUser extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $token;
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct($token, User $user)
|
||||
{
|
||||
|
||||
$this->token = $token;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Change E-Mail');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
/* $message = [
|
||||
'link' => route('user.update_email_confirm', $token),
|
||||
'line1' => 'Bitte aktivieren Sie Ihre neue E-Mail über diesen Link:',
|
||||
'line2' => 'oder kopieren Sie diesen Link in die Adressleiste Ihre Browsers.',
|
||||
];*/
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('user_update_email_confirm', $this->token),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Change E-Mail'),
|
||||
'copy1line' => __('Dear Customer you will receive this e-mail because we have received a request to change your E-Mail Address for your account.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'greetings' => __('Best regards'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
app/Mail/MailResetPassword.php
Normal file
48
app/Mail/MailResetPassword.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailResetPassword extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $token;
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct($token, $user)
|
||||
{
|
||||
|
||||
$this->token = $token;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Reset Password');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('password.reset', $this->token),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Reset Password'),
|
||||
'copy1line' => __('Dear Customer you will receive this e-mail because we have received a request to reset the password for your account.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'greetings' => __('Best regards'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
49
app/Mail/MailVerifyAccount.php
Normal file
49
app/Mail/MailVerifyAccount.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailVerifyAccount extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $confirmation_code;
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct($confirmation_code, User $user)
|
||||
{
|
||||
|
||||
$this->confirmation_code = $confirmation_code;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Verify Your Email Address');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('register_verify', $this->confirmation_code),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Verify Your Email Address'),
|
||||
'copy1line' => __('Thank you for creating an account with the JACKON Infomanager. Please follow the link below to confirm your email address.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'greetings' => __('Best regards'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
49
app/Mail/MailVerifyContact.php
Normal file
49
app/Mail/MailVerifyContact.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailVerifyContact extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $confirmation_code;
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct($confirmation_code, User $user)
|
||||
{
|
||||
|
||||
$this->confirmation_code = $confirmation_code;
|
||||
$this->user = $user;
|
||||
$this->subject = __('Verify your Data and E-Mail Address');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('Dear customer').",";
|
||||
if($this->user->account){
|
||||
if($this->user->account->salutation == "mr"){
|
||||
$salutation = __('Dear Sir')." ".$this->user->account->last_name.",";
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->user->account->last_name.",";
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view('emails.auth')->with([
|
||||
'url' => route('register_verify', $this->confirmation_code),
|
||||
'salutation' => $salutation,
|
||||
'button' => __('Verify your Data and E-Mail Address'),
|
||||
'copy1line' => __('We have data about you stored in our JACKON Infomanager. Please follow the link below to verify your email address.You can also change or delete your data.'),
|
||||
'copy2line' => __('Or copy this link into the address bar of your browser.'),
|
||||
'greetings' => __('Best regards'),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
73
app/Models/Account.php
Normal file
73
app/Models/Account.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Account
|
||||
*
|
||||
* @property-read \App\Models\Country $company_country
|
||||
* @property-read \App\Models\Country $company_pre_phone
|
||||
* @property-read \App\Models\Country $country
|
||||
* @property-read mixed $company
|
||||
* @property-read \App\Models\Country $pre_mobil
|
||||
* @property-read \App\Models\Country $pre_phone
|
||||
* @property-read \App\User $user
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Account withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
protected $table = 'accounts';
|
||||
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
|
||||
|
||||
public function company_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'company_country_id');
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'country_id');
|
||||
}
|
||||
|
||||
public function company_pre_phone()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'company_pre_phone_id');
|
||||
}
|
||||
|
||||
public function pre_phone()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'pre_phone_id');
|
||||
}
|
||||
|
||||
public function pre_mobil()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country', 'pre_mobil_id');
|
||||
}
|
||||
|
||||
public function getCompanyAttribute(){
|
||||
|
||||
if(empty($this->attributes['company']) && @$this->attributes['company'] !== 0){
|
||||
return 1;
|
||||
}
|
||||
return $this->attributes['company'];
|
||||
}
|
||||
}
|
||||
84
app/Models/Country.php
Normal file
84
app/Models/Country.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use PHPUnit\Framework\Constraint\Count;
|
||||
|
||||
/**
|
||||
* App\Models\Country
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $code
|
||||
* @property string $phone
|
||||
* @property string $en
|
||||
* @property string $de
|
||||
* @property string $es
|
||||
* @property string $fr
|
||||
* @property string $it
|
||||
* @property string $ru
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereDe($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEn($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereEs($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereFr($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereIt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'countries';
|
||||
|
||||
public function getLocated($lang = 'de'){
|
||||
|
||||
$lang = \App::getLocale();
|
||||
|
||||
if($lang == 'de'){
|
||||
return $this->de;
|
||||
}
|
||||
if($lang == 'en'){
|
||||
return $this->en;
|
||||
}
|
||||
if($lang == 'es'){
|
||||
return $this->es;
|
||||
}
|
||||
if($lang == 'fr'){
|
||||
return $this->fr;
|
||||
}
|
||||
if($lang == 'it'){
|
||||
return $this->it;
|
||||
}
|
||||
if($lang == 'ru'){
|
||||
return $this->ru;
|
||||
}
|
||||
return $this->de;
|
||||
}
|
||||
|
||||
public static function getCountryIdByCode($code){
|
||||
if($code == null){
|
||||
return null;
|
||||
}
|
||||
$r = Country::where('code', '=', $code)->first();
|
||||
if($r){
|
||||
return $r->id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCountryIdByPhone($phone){
|
||||
if($phone == null){
|
||||
return null;
|
||||
}
|
||||
$r = Country::where('phone', '=', $phone)->first();
|
||||
if($r){
|
||||
return $r->id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
69
app/Models/Draft.php
Normal file
69
app/Models/Draft.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\Draft
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Draft whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DraftItem[] $draft_items
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelProgramDraft[] $travel_program_drafts
|
||||
*/
|
||||
class Draft extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'drafts';
|
||||
|
||||
public function draft_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\DraftItem', 'draft_id', 'id')->orderBy('pos', 'ASC');
|
||||
}
|
||||
|
||||
public function travel_program_drafts()
|
||||
{
|
||||
return $this->hasMany(TravelProgramDraft::class, 'draft_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function findBeforeRelation($reid)
|
||||
{
|
||||
$before = false;
|
||||
foreach($this->draft_items as $draft_item) {
|
||||
if ($draft_item->id == $reid) {
|
||||
return $before;
|
||||
}
|
||||
$before = $draft_item;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function findAfterRelation($reid)
|
||||
{
|
||||
$next = false;
|
||||
foreach($this->draft_items as $draft_item) {
|
||||
if($next){
|
||||
return $draft_item;
|
||||
}
|
||||
if ($draft_item->id == $reid) {
|
||||
$next = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
108
app/Models/DraftItem.php
Normal file
108
app/Models/DraftItem.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\DraftItem
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $draft_id
|
||||
* @property int $draft_type_id
|
||||
* @property int|null $days_start
|
||||
* @property int|null $days_duration
|
||||
* @property string|null $name
|
||||
* @property float|null $price_adult
|
||||
* @property int|null $adult
|
||||
* @property float|null $price_children
|
||||
* @property int|null $children
|
||||
* @property string|null $content
|
||||
* @property int|null $pos
|
||||
* @property int $in_pdf
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Draft $draft
|
||||
* @property-read \App\Models\DraftType $draft_type
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereAdult($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereChildren($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereContent($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDaysDuration($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDaysStart($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDraftId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereDraftTypeId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereInPdf($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePriceAdult($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem wherePriceChildren($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $service
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftItem whereService($value)
|
||||
*/
|
||||
class DraftItem extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'draft_items';
|
||||
|
||||
protected $fillable = [
|
||||
'pos',
|
||||
];
|
||||
|
||||
public function draft()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Draft', 'draft_id');
|
||||
}
|
||||
|
||||
public function draft_type()
|
||||
{
|
||||
return $this->belongsTo('App\Models\DraftType', 'draft_type_id');
|
||||
}
|
||||
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setPriceAdultAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_adult'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getPriceAdultAttribute()
|
||||
{
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['price_adult']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceAdultRaw()
|
||||
{
|
||||
return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0;
|
||||
}
|
||||
|
||||
public function setPriceChildrenAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_children'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getPriceChildrenAttribute()
|
||||
{
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['price_children']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceChildrenRaw()
|
||||
{
|
||||
return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
37
app/Models/DraftType.php
Normal file
37
app/Models/DraftType.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\DraftType
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property int $active
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\DraftItem[] $draft_items
|
||||
*/
|
||||
class DraftType extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'draft_types';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'active',
|
||||
];
|
||||
|
||||
public function draft_items()
|
||||
{
|
||||
return $this->hasMany('App\Models\DraftItem', 'draft_type_id', 'id');
|
||||
}
|
||||
}
|
||||
59
app/Models/SfGuardUser.php
Executable file
59
app/Models/SfGuardUser.php
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\SfGuardUser
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $user_id
|
||||
* @property string $username
|
||||
* @property string $algorithm
|
||||
* @property string|null $salt
|
||||
* @property string|null $password
|
||||
* @property int|null $is_active
|
||||
* @property int|null $is_super_admin
|
||||
* @property string|null $last_login
|
||||
* @property string|null $first_name
|
||||
* @property string|null $last_name
|
||||
* @property string|null $email_address
|
||||
* @property string|null $default_page
|
||||
* @property int|null $branch_id
|
||||
* @property string|null $api_key
|
||||
* @property string|null $identify
|
||||
* @property string|null $token
|
||||
* @property string|null $token_at
|
||||
* @property \Illuminate\Support\Carbon $created_at
|
||||
* @property \Illuminate\Support\Carbon $updated_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereAlgorithm($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereApiKey($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereBranchId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereDefaultPage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereEmailAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereFirstName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereIdentify($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereIsActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereIsSuperAdmin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereLastLogin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereLastName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereSalt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereTokenAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser whereUsername($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class SfGuardUser extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'sf_guard_user';
|
||||
|
||||
}
|
||||
39
app/Models/Sym/Arrangement.php
Normal file
39
app/Models/Sym/Arrangement.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Sym;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Sym\Arrangement
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $template_id
|
||||
* @property string|null $state
|
||||
* @property string|null $begin
|
||||
* @property string|null $end
|
||||
* @property string|null $type_s
|
||||
* @property string|null $data_s
|
||||
* @property int|null $view_position
|
||||
* @property int|null $booking_id
|
||||
* @property int $type_id
|
||||
* @property int|null $in_pdf
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereBegin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereBookingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereDataS($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereEnd($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereInPdf($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereState($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereTemplateId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereTypeId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereTypeS($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\Arrangement whereViewPosition($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Arrangement extends Model
|
||||
{
|
||||
protected $table = 'arrangement';
|
||||
|
||||
}
|
||||
27
app/Models/Sym/ArrangementTemplate.php
Normal file
27
app/Models/Sym/ArrangementTemplate.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Sym;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Sym\ArrangementTemplate
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $title
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Sym\Arrangement[] $arrangements
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\ArrangementTemplate whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\ArrangementTemplate whereTitle($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ArrangementTemplate extends Model
|
||||
{
|
||||
protected $table = 'arrangement_template';
|
||||
|
||||
public function arrangements()
|
||||
{
|
||||
return $this->hasMany('App\Models\Sym\Arrangement', 'template_id', 'id')->orderBy('view_position', 'DESC');
|
||||
}
|
||||
|
||||
}
|
||||
52
app/Models/TravelClass.php
Normal file
52
app/Models/TravelClass.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\TravelClass
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $name
|
||||
* @property string|null $description
|
||||
* @property int|null $program_id
|
||||
* @property int $standard
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\TravelProgram|null $travel_program
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereProgramId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereStandard($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelClass whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelProgramDraft[] $travel_program_drafts
|
||||
*/
|
||||
class TravelClass extends Model
|
||||
{
|
||||
//use the connection to sec. Datebase sterntours
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_class';
|
||||
|
||||
protected $fillable = [
|
||||
'program_id',
|
||||
'name',
|
||||
'description',
|
||||
'standard',
|
||||
];
|
||||
|
||||
public function travel_program()
|
||||
{
|
||||
return $this->belongsTo('App\Models\TravelProgram', 'program_id');
|
||||
}
|
||||
|
||||
public function travel_program_drafts()
|
||||
{
|
||||
return $this->hasMany('App\Models\TravelProgramDraft', 'travel_class_id', 'id');
|
||||
}
|
||||
}
|
||||
158
app/Models/TravelProgram.php
Normal file
158
app/Models/TravelProgram.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\TravelProgram
|
||||
*
|
||||
* @property int $id
|
||||
* @property float|null $profit_margin
|
||||
* @property int|null $category_id
|
||||
* @property string|null $program_code
|
||||
* @property int|null $program_duration
|
||||
* @property int|null $is_seasonal
|
||||
* @property int|null $youth
|
||||
* @property string|null $title
|
||||
* @property string|null $subtitle
|
||||
* @property string|null $slider_info
|
||||
* @property int|null $program_type
|
||||
* @property int|null $crm_draft_id_standard
|
||||
* @property int|null $crm_draft_id_comfort
|
||||
* @property int|null $organizer
|
||||
* @property int|null $generalnote
|
||||
* @property int|null $status
|
||||
* @property string|null $included
|
||||
* @property string|null $class_description
|
||||
* @property string|null $excluded
|
||||
* @property string|null $advices
|
||||
* @property string|null $notes
|
||||
* @property string|null $url
|
||||
* @property int|null $max_age_for_children
|
||||
* @property string|null $html_description
|
||||
* @property int|null $insurance_1
|
||||
* @property int|null $insurance_2
|
||||
* @property int|null $insurance_3
|
||||
* @property int $in_slider
|
||||
* @property int $show_map
|
||||
* @property string|null $map_html
|
||||
* @property string $map_image
|
||||
* @property string $map_image_ext
|
||||
* @property int|null $travel_country
|
||||
* @property int|null $travel_category
|
||||
* @property int|null $travel_agenda
|
||||
* @property int|null $deposit_percent
|
||||
* @property int|null $netto_prices_in_euro
|
||||
* @property string|null $text_right
|
||||
* @property float|null $default_flight_price
|
||||
* @property int|null $travel_arrival_point_id
|
||||
* @property string|null $weekdays
|
||||
* @property int|null $position
|
||||
* @property float|null $discount
|
||||
* @property int|null $discount_is_percent_value
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereAdvices($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCategoryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereClassDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCrmDraftIdComfort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCrmDraftIdStandard($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDefaultFlightPrice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDepositPercent($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDiscount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDiscountIsPercentValue($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereExcluded($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereGeneralnote($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereHtmlDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInSlider($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereIncluded($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance1($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance2($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance3($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereIsSeasonal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapHtml($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapImage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapImageExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMaxAgeForChildren($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereNettoPricesInEuro($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereNotes($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereOrganizer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram wherePosition($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProfitMargin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramDuration($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereShowMap($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereSliderInfo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereSubtitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTextRight($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTitle($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelAgenda($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelArrivalPointId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelCategory($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereUrl($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereWeekdays($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereYouth($value)
|
||||
* @mixin \Eloquent
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelClass[] $classes
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereUpdatedAt($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelProgramDraft[] $travel_program_drafts
|
||||
*/
|
||||
class TravelProgram extends Model
|
||||
{
|
||||
//use the connection to sec. Datebase sterntours
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_program';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'subtitle',
|
||||
'program_code',
|
||||
'weekdays',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function classes()
|
||||
{
|
||||
return $this->hasMany('App\Models\TravelClass', 'program_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_program_drafts()
|
||||
{
|
||||
return $this->hasMany('App\Models\TravelProgramDraft', 'travel_program_id', 'id');
|
||||
}
|
||||
|
||||
public function getWeekdaysArray(){
|
||||
if($this->weekdays){
|
||||
return explode(',', $this->weekdays);
|
||||
}
|
||||
if($this->weekdays !== NULL){
|
||||
return array(0);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function setWeekdaysFromArray($value){
|
||||
if($value){
|
||||
if(is_array($value)){
|
||||
if($value[0] === NULL){
|
||||
$this->weekdays = "0,1,2,3,4,5,6";
|
||||
}else{
|
||||
$this->weekdays = implode(',', $value);
|
||||
}
|
||||
}else{
|
||||
$this->weekdays = $value;
|
||||
}
|
||||
return $this->weekdays;
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
58
app/Models/TravelProgramDraft.php
Normal file
58
app/Models/TravelProgramDraft.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\TravelProgramDraft
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_program_id
|
||||
* @property int $travel_class_id
|
||||
* @property int $draft_id
|
||||
* @property array $weekdays
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\Draft $draft
|
||||
* @property-read \App\Models\TravelClass $travel_class
|
||||
* @property-read \App\Models\TravelProgram $travel_program
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereDraftId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereTravelClassId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereTravelProgramId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgramDraft whereWeekdays($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelProgramDraft extends Model
|
||||
{
|
||||
//use the connection to sec. Datebase sterntours
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_program_drafts';
|
||||
|
||||
protected $casts = ['weekdays' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_program_id',
|
||||
'travel_class_id',
|
||||
'draft_id',
|
||||
'weekdays',
|
||||
];
|
||||
|
||||
|
||||
public function travel_program()
|
||||
{
|
||||
return $this->belongsTo('App\Models\TravelProgram', 'travel_program_id');
|
||||
}
|
||||
public function travel_class()
|
||||
{
|
||||
return $this->belongsTo('App\Models\TravelClass', 'travel_class_id');
|
||||
}
|
||||
public function draft()
|
||||
{
|
||||
return $this->belongsTo(Draft::class, 'draft_id', 'id');
|
||||
}
|
||||
}
|
||||
27
app/Models/UserUpdateEmail.php
Normal file
27
app/Models/UserUpdateEmail.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* App\Models\UserUpdateEmail
|
||||
*
|
||||
* @property-read \App\User $user
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserUpdateEmail extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'users_update_email';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'email', 'token',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'user_id');
|
||||
}
|
||||
}
|
||||
32
app/Providers/AppServiceProvider.php
Executable file
32
app/Providers/AppServiceProvider.php
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->environment() !== 'production') {
|
||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||
}
|
||||
// ...
|
||||
}
|
||||
}
|
||||
33
app/Providers/AuthServiceProvider.php
Executable file
33
app/Providers/AuthServiceProvider.php
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Laravel\Passport\Passport;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
Passport::routes();
|
||||
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Executable file
21
app/Providers/BroadcastServiceProvider.php
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
32
app/Providers/EventServiceProvider.php
Executable file
32
app/Providers/EventServiceProvider.php
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
73
app/Providers/RouteServiceProvider.php
Executable file
73
app/Providers/RouteServiceProvider.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
68
app/Repositories/BaseRepository.php
Normal file
68
app/Repositories/BaseRepository.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
abstract class BaseRepository {
|
||||
|
||||
/**
|
||||
* The Model instance.
|
||||
*
|
||||
* @var Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Get number of records.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
$total = $this->model->count();
|
||||
|
||||
$new = $this->model->whereSeen(0)->count();
|
||||
|
||||
return compact('total', 'new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a model.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->getById($id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Model by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @return App\Models\Model
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
return $this->model->findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Model by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @return App\Models\Model
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->model->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
}
|
||||
101
app/Repositories/TravelProgramRepository.php
Normal file
101
app/Repositories/TravelProgramRepository.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
|
||||
|
||||
use App\Models\TravelClass;
|
||||
use App\Models\TravelProgram;
|
||||
use App\Models\TravelProgramDraft;
|
||||
|
||||
class TravelProgramRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(TravelProgram $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
if($data['id'] == "new"){
|
||||
$this->model = TravelProgram::createNew();
|
||||
}
|
||||
else{
|
||||
$this->model = $this->getById($data['id']);
|
||||
}
|
||||
$this->checkDraftsWeekdays($data['weekdays']);
|
||||
$data['weekdays'] = $this->model->setWeekdaysFromArray($data['weekdays']);
|
||||
$this->model->fill($data);
|
||||
$this->model->status = isset($data['status']) ? true : false;
|
||||
$this->model->save();
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function checkDraftsWeekdays($weekdays){
|
||||
if(isset($weekdays) && is_array($weekdays) && $weekdays[0] === NULL){
|
||||
$weekdays = range(0, 6);
|
||||
}
|
||||
foreach($this->model->travel_program_drafts as $travel_program_draft){
|
||||
if($travel_program_draft->weekdays !== NULL){
|
||||
$wd = [];
|
||||
foreach ($travel_program_draft->weekdays as $weekday){
|
||||
if(in_array($weekday, $weekdays)){
|
||||
$wd[] = $weekday;
|
||||
}
|
||||
}
|
||||
if(count($wd)){
|
||||
$travel_program_draft->weekdays = $wd;
|
||||
}else{
|
||||
$travel_program_draft->weekdays = NULL;
|
||||
}
|
||||
$travel_program_draft->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateClass($data)
|
||||
{
|
||||
if($data['id'] == "new"){
|
||||
$travel_class = TravelClass::create([
|
||||
'program_id' => $data['program_id'],
|
||||
'name' => $data['name'],
|
||||
'standard' => isset($data['standard']) ? true : false,
|
||||
'description' => $data['description'],
|
||||
]);
|
||||
}else {
|
||||
$travel_class = TravelClass::findOrFail($data['id']);
|
||||
$travel_class->name = $data['name'];
|
||||
$travel_class->standard = isset($data['standard']) ? true : false;
|
||||
$travel_class->description = $data['description'];
|
||||
$travel_class->save();
|
||||
}
|
||||
return $travel_class;
|
||||
}
|
||||
|
||||
public function updateDraft($data)
|
||||
{
|
||||
if(isset($data['weekdays']) && count($data['weekdays']) > 1 && in_array(NULL, $data['weekdays'])){
|
||||
$data['weekdays'] = array_filter($data['weekdays'], 'is_numeric');
|
||||
sort($data['weekdays']);
|
||||
}
|
||||
if($data['id'] == "new"){
|
||||
$travel_program_draft = TravelProgramDraft::create([
|
||||
'travel_program_id' => $data['travel_program_id'],
|
||||
'travel_class_id' => $data['travel_class_id'],
|
||||
'draft_id' => $data['draft_id'],
|
||||
'weekdays' => isset($data['weekdays']) ? $data['weekdays'] : null,
|
||||
]);
|
||||
}else{
|
||||
$travel_program_draft = TravelProgramDraft::findOrFail($data['id']);
|
||||
$travel_program_draft->draft_id = $data['draft_id'];
|
||||
$travel_program_draft->travel_class_id = $data['travel_class_id'];
|
||||
$travel_program_draft->weekdays = isset($data['weekdays']) ? $data['weekdays'] : null;
|
||||
$travel_program_draft->save();
|
||||
}
|
||||
return $travel_program_draft;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
113
app/Repositories/UserRepository.php
Normal file
113
app/Repositories/UserRepository.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\User;
|
||||
|
||||
|
||||
class UserRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(User $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* refresh.
|
||||
*/
|
||||
/*public function update($data)
|
||||
{
|
||||
|
||||
if($data['user_id'] == "new"){
|
||||
|
||||
$this->model = User::create([
|
||||
'email' => $data['email'],
|
||||
'password' => env('APP_KEY'),
|
||||
]);
|
||||
}
|
||||
else{
|
||||
$this->model = $this->getById($data['user_id']);
|
||||
}
|
||||
|
||||
if(!$this->model->account_id){
|
||||
$account = new UserAccount();
|
||||
}else{
|
||||
$account = $this->model->account;
|
||||
}
|
||||
|
||||
$account->company = $data['company'];
|
||||
|
||||
$account->company_name = $data['company_name'];
|
||||
$account->company_street = $data['company_street'];
|
||||
$account->company_postal_code = $data['company_postal_code'];
|
||||
$account->company_city = $data['company_city'];
|
||||
$account->company_country_id = isset($data['company_country_id']) ? $data['company_country_id'] : null;
|
||||
|
||||
$account->company_pre_phone_id = isset($data['company_pre_phone_id']) ? $data['company_pre_phone_id']: null;
|
||||
$account->company_phone = $data['company_phone'];
|
||||
$account->company_homepage = $data['company_homepage'];
|
||||
|
||||
|
||||
$account->position_text = $data['position_text'];
|
||||
$account->salutation = $data['salutation'];
|
||||
$account->title = $data['title'];
|
||||
$account->first_name = $data['first_name'];
|
||||
$account->last_name = $data['last_name'];
|
||||
|
||||
$account->street = $data['street'];
|
||||
$account->postal_code = $data['postal_code'];
|
||||
$account->city = $data['city'];
|
||||
$account->country_id = isset($data['country_id']) ? $data['country_id'] : null;
|
||||
|
||||
$account->pre_phone_id = isset($data['pre_phone_id']) ? $data['pre_phone_id']: null;
|
||||
$account->phone = $data['phone'];
|
||||
|
||||
$account->pre_mobil_id = isset($data['pre_mobil_id']) ? $data['pre_mobil_id']: null;
|
||||
$account->mobil = $data['mobil'];
|
||||
|
||||
$account->contactpartner = $data['contactpartner'];
|
||||
|
||||
//data_protection
|
||||
//active_date
|
||||
//active
|
||||
$account->save();
|
||||
|
||||
if(!$this->model->account_id){
|
||||
$this->model->account_id = $account->id;
|
||||
$this->model->save();
|
||||
}
|
||||
|
||||
$this->updateInterests(isset($data['interests']) ? $data['interests'] : array());
|
||||
$this->updateIndustrySector(isset($data['industry_sectors']) ? $data['industry_sectors'] : array());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
if($user->account){
|
||||
$user->account->delete();
|
||||
}
|
||||
$user->email = "delete".time();
|
||||
$user->password = "";
|
||||
$user->confirmed = 0;
|
||||
$user->confirmation_code = "delete".time();
|
||||
$user->confirmation_date = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 2;
|
||||
$user->agreement = null;
|
||||
$user->active = 0;
|
||||
$user->token = '';
|
||||
$user->active_date = null;
|
||||
$user->admin = 0;
|
||||
$user->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
253
app/Services/HTMLHelper.php
Normal file
253
app/Services/HTMLHelper.php
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Draft;
|
||||
use App\Models\DraftType;
|
||||
use App\Models\IndustrySector;
|
||||
use App\Models\Interest;
|
||||
use App\Models\TravelClass;
|
||||
use App\Models\TravelProgram;
|
||||
use Form;
|
||||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
||||
|
||||
private static $months = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember',
|
||||
];
|
||||
|
||||
private static $days = [
|
||||
0 => 'Sonntag',
|
||||
1=> 'Montag',
|
||||
2 => 'Dienstag',
|
||||
3 => 'Mittwoch',
|
||||
4 => 'Donnerstag',
|
||||
5 => 'Freitag',
|
||||
6 => 'Samstag',
|
||||
];
|
||||
|
||||
|
||||
private static $roles = [
|
||||
0 => 'Kunde',
|
||||
1 => 'Admin',
|
||||
2 => 'SuperAdmin',
|
||||
];
|
||||
|
||||
|
||||
public static function getMonth($i){
|
||||
return self::$months[intval($i)];
|
||||
}
|
||||
|
||||
public static function getDay($i){
|
||||
return self::$days[intval($i)];
|
||||
}
|
||||
|
||||
public static function getRoleLabel($role_id = 0){
|
||||
return '<span class="badge badge-pill '.self::getLable($role_id).'">'.self::$roles[$role_id].'</span>';
|
||||
}
|
||||
|
||||
public static function getLable($id){
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return 'badge-default';
|
||||
break;
|
||||
case 1:
|
||||
return 'badge-warning';
|
||||
break;
|
||||
case 2:
|
||||
return 'badge-primary';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getRolesOptions(){
|
||||
$ret = "";
|
||||
foreach (self::$roles as $role_id => $value){
|
||||
$ret .= '<option value="'.$role_id.'">'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getYearSelectOptions(){
|
||||
$start = date("Y", strtotime("-5 years", time()));
|
||||
$end = date("Y", strtotime("+1 years", time()));
|
||||
$values = range($start, $end);
|
||||
$now = date("Y", time());
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
$attr = ($value == $now) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getDraftTypes($setId = false){
|
||||
$options = DraftType::all()->sortByDesc('id');
|
||||
$ret = "";
|
||||
foreach ($options as $option){
|
||||
$attr = ($option->id == $setId) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getRangeOptions($id = false, $range = 30, $name = ""){
|
||||
|
||||
$range = range(1, $range);
|
||||
$ret = "";
|
||||
|
||||
foreach ($range as $item){
|
||||
$attr = ($item === $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$item.'" '.$attr.'>'.$item.$name.'</option>\n';
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getDraftOptions($setId = false){
|
||||
|
||||
$options = Draft::where('active', 1)->orderBy('id', 'DESC')->get();
|
||||
$ret = "";
|
||||
foreach ($options as $option){
|
||||
$attr = ($option->id === $setId) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getTravelClassOptions($programId = false, $setId = false){
|
||||
$options = TravelClass::where('program_id', $programId)->get();
|
||||
$ret = '<option value="">alle Kategorien</option>\n';
|
||||
foreach ($options as $option){
|
||||
$attr = ($option->id === $setId) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getWeekdaysOptions($programId = false, $weekdays = []){
|
||||
if($programId){
|
||||
$tp = TravelProgram::findOrFail($programId);
|
||||
$options = explode(',', $tp->weekdays);
|
||||
}else{
|
||||
$options = range(0, 6);
|
||||
}
|
||||
$ret = '<option value="">alle Wochentage</option>\n';
|
||||
foreach ($options as $option){
|
||||
$attr = (in_array($option, $weekdays)) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option.'" '.$attr.'>'.self::getDay($option).'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getWeekdaysString($weekdays = []){
|
||||
|
||||
$ret = "";
|
||||
if(count($weekdays)){
|
||||
foreach($weekdays as $weekday){
|
||||
if($weekday !== NULL){
|
||||
$ret .= self::getDay($weekday).', ';
|
||||
}
|
||||
}
|
||||
if($ret != ""){
|
||||
return rtrim($ret, ", ");
|
||||
}
|
||||
}
|
||||
return "alle Wochentage";
|
||||
}
|
||||
|
||||
/*
|
||||
public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = IndustrySector::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('no').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if($sameId == $value->id){
|
||||
continue;
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getContriesWithMore($id, $all=true){#
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
if( $counter == 7){
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->getLocated().'</option>\n';
|
||||
|
||||
$counter ++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getContriesCodes($id, $all=true){#
|
||||
$values = Country::all();
|
||||
$counter = 1;
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
|
||||
}
|
||||
foreach ($values as $value){
|
||||
|
||||
if(!$value->phone) continue;
|
||||
if( $counter == 7){
|
||||
$ret .= '<optgroup label="'.__('further countrie').'">';
|
||||
}
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->phone.'('.$value->getLocated().')</option>\n';
|
||||
|
||||
$counter ++;
|
||||
}
|
||||
$ret .= '</optgroup>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getSalutation($id){
|
||||
$values = array('mr' => __('MR'), 'ms' => __('MS'));
|
||||
$ret = "";
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
foreach ($values as $key => $value){
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getSalutationLang($id){
|
||||
$values = array('mr' => __('MR'), 'ms' => __('MS'));
|
||||
return (!empty($values[$id]) ? $values[$id] : '');
|
||||
}
|
||||
*/
|
||||
}
|
||||
31
app/Services/Util.php
Normal file
31
app/Services/Util.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
|
||||
class Util
|
||||
{
|
||||
|
||||
|
||||
public static function formatDate(){
|
||||
if(\App::getLocale() == "en"){
|
||||
return 'yyyy-mm-dd';
|
||||
}
|
||||
return 'dd.mm.yyyy';
|
||||
|
||||
}
|
||||
|
||||
public static function formatDateDB(){
|
||||
if(\App::getLocale() == "en"){
|
||||
return 'Y-m-d';
|
||||
}
|
||||
return 'd.m.Y';
|
||||
}
|
||||
|
||||
public static function formatDateTimeDB(){
|
||||
if(\App::getLocale() == "en"){
|
||||
return 'Y-m-d - H:i';
|
||||
}
|
||||
return 'd.m.Y - H:i';
|
||||
}
|
||||
}
|
||||
203
app/User.php
Executable file
203
app/User.php
Executable file
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\MailResetPassword;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
|
||||
|
||||
/**
|
||||
* App\User
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string|null $remember_token
|
||||
* @property string|null $token
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $confirmed
|
||||
* @property string|null $confirmation_code
|
||||
* @property string|null $confirmation_date
|
||||
* @property string|null $confirmation_code_to
|
||||
* @property int|null $confirmation_code_remider
|
||||
* @property int|null $active
|
||||
* @property string|null $active_date
|
||||
* @property string|null $agreement
|
||||
* @property int|null $admin
|
||||
* @property string|null $identify
|
||||
* @property string|null $lang
|
||||
* @property string|null $last_login
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \App\Models\Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserUpdateEmail[] $user_update_email
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereActiveDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereAdmin($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereAgreement($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereConfirmationCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereConfirmationCodeRemider($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereConfirmationCodeTo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereConfirmationDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereConfirmed($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereIdentify($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereLang($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereLastLogin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User withoutTrashed()
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Client[] $clients
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Token[] $tokens
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, Notifiable;
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'users';
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password', 'token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token', 'token',
|
||||
];
|
||||
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->hasOne('App\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function user_update_email()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPasswort(){
|
||||
if($this->password == env('APP_KEY')){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAdmin()
|
||||
{
|
||||
if($this->admin >= 1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuperAdmin()
|
||||
{
|
||||
if($this->admin >= 2){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getConfirmationDateFormat(){
|
||||
if(!$this->attributes['confirmation_date']){ return ""; }
|
||||
return Carbon::parse($this->attributes['confirmation_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getActiveDateFormat(){
|
||||
if(!$this->attributes['active_date']){ return ""; }
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAgreementFormat(){
|
||||
if(!$this->attributes['agreement']){ return ""; }
|
||||
return Carbon::parse($this->attributes['agreement'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLandByCountry(){
|
||||
if($this->account && $this->account->country_id){
|
||||
$code = $this->account->country->code;
|
||||
if($code == "FR"){
|
||||
return 'fr';
|
||||
}
|
||||
if($code == "CH"){
|
||||
return 'de';
|
||||
}
|
||||
if($code == "NL"){
|
||||
return 'nl';
|
||||
}
|
||||
if($code == "DE"){
|
||||
return 'de';
|
||||
}
|
||||
}
|
||||
return "en";
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
Mail::to($this->email)->send(new MailResetPassword($token, $this));
|
||||
// $this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
}
|
||||
8
app/helpers.php
Normal file
8
app/helpers.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
if (! function_exists('make_old_url')) {
|
||||
function make_old_url($path)
|
||||
{
|
||||
return config('app.old_url').$path;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue