First Commit

This commit is contained in:
Kevin Adametz 2018-10-29 09:39:31 +01:00
commit 610aa1e202
4204 changed files with 636764 additions and 0 deletions

42
app/Console/Kernel.php Executable file
View 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
View 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);
}
}

View 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');
}
}

View 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');
}
}

View 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'),
]);
}
*/
}

View 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']),
]);
}
}

View 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');
}
}

View 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;
}

View 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");
}
}

View 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);
}
}
/**/

View 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('/templates');
}
}
return abort(404);
}
public function legalDataProtected()
{
return view('legal.data_protected');
}
public function legalImprint()
{
return view('legal.imprint');
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers;
use App\User;
use App\Http\Controllers\Controller;
use Auth;
class TemplateController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
if(Auth::check()) {
}
return view('templates.index', ['title' => 'Page 2']);
}
}

View 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("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
"}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;",
"—", "–", ",", "<", ".", ">", "/", "?");
$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;
}
}

View 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');
}
}

View 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'));
}
}
}

View 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();
}
}

View 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
View 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
View 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');
}
}

View 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 = [
//
];
}

View 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);
}
}

View 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);
}
}

View 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');
}
}

View 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',
];
}

View 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;
}

View 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 = [
//
];
}

View 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'),
]);
}
}

View 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'),
]);
}
}

View 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'),
]);
}
}

View 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'),
]);
}
}

134
app/Models/Account.php Normal file
View file

@ -0,0 +1,134 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Account
*
* @property int $id
* @property int $user_id
* @property int $company
* @property string|null $company_name
* @property string|null $company_street
* @property string|null $company_postal_code
* @property string|null $company_city
* @property int|null $company_pre_phone_id
* @property string|null $company_phone
* @property string|null $company_homepage
* @property int|null $company_country_id
* @property string|null $salutation
* @property string|null $title
* @property string|null $first_name
* @property string|null $last_name
* @property string|null $street
* @property string|null $postal_code
* @property string|null $city
* @property int|null $country_id
* @property int|null $pre_phone_id
* @property string|null $phone
* @property int|null $pre_mobil_id
* @property string|null $mobil
* @property string|null $birthday
* @property string|null $website
* @property string|null $facebook
* @property string|null $facebook_fanpage
* @property string|null $instagram
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\Country|null $company_country
* @property-read \App\Models\Country|null $company_pre_phone
* @property-read \App\Models\Country|null $country
* @property-read \App\Models\Country|null $pre_mobil
* @property-read \App\Models\Country|null $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\Eloquent\Builder|\App\Models\Account whereBirthday($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyHomepage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyPrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCompanyStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebook($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFacebookFanpage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereFirstName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereInstagram($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereLastName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereMobil($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePostalCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePreMobilId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account wherePrePhoneId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereSalutation($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Account whereWebsite($value)
* @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'];
}
}

85
app/Models/Attribute.php Normal file
View file

@ -0,0 +1,85 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Attribute
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Attribute[] $childrens
* @property-read \App\Models\Attribute|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Attribute extends Model
{
protected $table = 'attributes';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'parent_id', 'name', 'pos', 'active',
];
public function parent()
{
return $this->belongsTo('App\Models\Attribute', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Attribute', 'parent_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

85
app/Models/Category.php Normal file
View file

@ -0,0 +1,85 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Category
*
* @property int $id
* @property int|null $parent_id
* @property string $name
* @property array|null $trans_name
* @property int|null $pos
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Category[] $childrens
* @property-read \App\Models\Category|null $parent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereParentId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Category extends Model
{
protected $table = 'categories';
protected $casts = ['trans_name' => 'array'];
protected $fillable = [
'parent_id', 'name', 'pos', 'active',
];
public function parent()
{
return $this->belongsTo('App\Models\Category', 'parent_id');
}
public function childrens()
{
return $this->hasMany('App\Models\Category', 'parent_id', 'id');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

83
app/Models/Country.php Normal file
View file

@ -0,0 +1,83 @@
<?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 $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;
}
}

194
app/Models/Product.php Normal file
View file

@ -0,0 +1,194 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\Product
*
* @property int $id
* @property string $name
* @property array|null $trans_name
* @property string $title
* @property array|null $trans_title
* @property string|null $copy
* @property array|null $trans_copy
* @property float|null $price
* @property float|null $price_ek
* @property float|null $tax
* @property float|null $price_old
* @property string|null $contents
* @property string|null $number
* @property array|null $icons
* @property string|null $description
* @property array|null $trans_description
* @property string|null $usage
* @property array|null $trans_usage
* @property string|null $ingredients
* @property array|null $trans_ingredients
* @property int|null $pos
* @property int $active
* @property int|null $amount
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductAttribute[] $attributes
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $images
* @property-write mixed $price_vk
* @method static bool|null forceDelete()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product onlyTrashed()
* @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereContents($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIcons($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIngredients($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePriceEk($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePriceOld($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransCopy($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransIngredients($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereTransUsage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUsage($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
* @mixin \Eloquent
*/
class Product extends Model
{
protected $table = 'products';
protected $casts = [
'trans_name' => 'array',
'trans_title' => 'array',
'trans_copy' => 'array',
'icons' => 'array',
'trans_description' => 'array',
'trans_usage' => 'array',
'trans_ingredients' => 'array'
];
use SoftDeletes;
protected $dates = ['deleted_at'];
public function attributes(){
return $this->hasMany('App\Models\ProductAttribute', 'product_id', 'id');
}
public function categories(){
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id');
}
public function images(){
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id');
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
public function setPriceAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
}
public function setPriceVkAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_ek'] = floatval(str_replace(',', '.', $value));
}
public function setTaxAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
}
public function setPriceOldAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_old'] = floatval(str_replace(',', '.', $value));
}
public function getFormattedPrice()
{
if(\App::getLocale() == "en"){
return number_format($this->attributes['price'], 2, '.', ',');
}
return number_format($this->attributes['price'], 2, ',', '.');
}
public function getFormattedPriceVk()
{
if(\App::getLocale() == "en"){
return number_format($this->attributes['price_ek'], 2, '.', ',');
}
return number_format($this->attributes['price_ek'], 2, ',', '.');
}
public function getFormattedTax()
{
if(\App::getLocale() == "en"){
return number_format($this->attributes['tax'], 2, '.', ',');
}
return number_format($this->attributes['tax'], 2, ',', '.');
}
public function getFormattedPriceOld()
{
if(\App::getLocale() == "en"){
return number_format($this->attributes['price_old'], 2, '.', ',');
}
return number_format($this->attributes['price_old'], 2, ',', '.');
}
public function setPosAttribute($value){
$this->attributes['pos'] = is_numeric($value) ? $value : null;
}
public function getLang($key)
{
$lang = \App::getLocale();
if ($lang == 'de') {
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
public function getTrans($key, $lang)
{
$key = 'trans_' . $key;
if (!empty($this->{$key}[$lang])) {
return $this->{$key}[$lang];
}
}
public function getTranNames()
{
$ret = "";
foreach ((array) $this->trans_name as $value){
$ret .= $value.', ';
}
return rtrim($ret, ', ');
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductAttribute
*
* @property int $id
* @property int $product_id
* @property int $attribute_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Attribute $attribute
* @property-read \App\Models\Product $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereAttributeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ProductAttribute extends Model
{
protected $table = 'product_attributes';
protected $fillable = [
'product_id', 'attribute_id',
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function attribute()
{
return $this->belongsTo('App\Models\Attribute', 'attribute_id');
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductCategory
*
* @property int $id
* @property int $product_id
* @property int $category_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Category $category
* @property-read \App\Models\Product $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ProductCategory extends Model
{
protected $table = 'product_categories';
protected $fillable = [
'product_id', 'category_id',
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function category()
{
return $this->belongsTo('App\Models\Category', 'category_id');
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\ProductImage
*
* @property int $id
* @property int|null $product_id
* @property string $filename
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property int $active
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Product|null $product
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereFilename($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereMine($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereOriginalName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ProductImage extends Model
{
protected $table = 'product_images';
protected $fillable = [
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
];
public function product()
{
return $this->belongsTo('App\Models\Product', 'product_id');
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\UserUpdateEmail
*
* @property-read \App\User $user
* @mixin \Eloquent
*/
class UserUpdateEmail extends Model
{
protected $table = 'users_update_email';
protected $fillable = [
'user_id', 'email', 'token',
];
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}
}

View 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);
}
// ...
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
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();
//
}
}

View 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');
}
}

View 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();
//
}
}

View 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'));
}
}

View 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;
}
}

View 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;
}
}

168
app/Services/HTMLHelper.php Normal file
View file

@ -0,0 +1,168 @@
<?php
namespace App\Services;
use App\Models\Country;
use App\Models\IndustrySector;
use App\Models\Interest;
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 $roles = [
0 => 'Kunde',
1 => 'Admin',
2 => 'SuperAdmin',
];
public static function getMonth($i){
return self::$months[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 getCompanyOptions($company){
$options = array(1 => __('business'), 0 => __('private'), );
$ret = "";
foreach ($options as $id => $value){
$attr = ($id == $company) ? 'selected="selected"' : '';
$ret .= '<option value="'.$id.'" '.$attr.'>'.$value.'</option>\n';
}
return $ret;
}
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
View 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';
}
}

200
app/User.php Executable file
View file

@ -0,0 +1,200 @@
<?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;
/**
* 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 $confirmed
* @property string|null $confirmation_code
* @property string|null $confirmation_date
* @property string|null $confirmation_code_to
* @property int $confirmation_code_remider
* @property int $active
* @property string|null $active_date
* @property string|null $agreement
* @property int $admin
* @property string $lang
* @property string|null $notes
* @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 whereLang($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereLastLogin($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereNotes($value)
* @method static \Illuminate\Database\Query\Builder|\App\User withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\User withoutTrashed()
*/
class User extends Authenticatable
{
use 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
View file

@ -0,0 +1,8 @@
<?php
if (! function_exists('make_old_url')) {
function make_old_url($path)
{
return config('app.old_url').$path;
}
}