246 lines
6.1 KiB
PHP
Executable file
246 lines
6.1 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\ShoppingPayment;
|
|
use App\User;
|
|
use Auth;
|
|
use Carbon\Carbon;
|
|
use Config;
|
|
use Request;
|
|
use Input;
|
|
use Util;
|
|
|
|
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"){
|
|
$data = [
|
|
'modal' => true,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
$response = view('legal.data_protect_de', $data)->render();
|
|
}
|
|
if($data == "imprint"){
|
|
$data = [
|
|
'modal' => true,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
$response = view('legal.imprint_de', $data)->render();
|
|
}
|
|
if($data == "shop_term_of_use"){
|
|
$data = [
|
|
'modal' => true,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
$response = view('legal.shop_term_of_use_de', $data)->render();
|
|
}
|
|
if($data == "agb"){
|
|
$data = [
|
|
'modal' => true,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
$response = view('legal.agb_de', $data)->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()
|
|
{
|
|
$data = [
|
|
'modal' => false,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
return view('legal.data_protected', $data);
|
|
}
|
|
|
|
public function legalAGB()
|
|
{
|
|
$data = [
|
|
'modal' => false,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
return view('legal.agb', $data);
|
|
}
|
|
|
|
public function legalImprint()
|
|
{
|
|
$data = [
|
|
'modal' => false,
|
|
'user_shop' => Util::getUserShop(),
|
|
];
|
|
return view('legal.imprint', $data);
|
|
}
|
|
|
|
public function verify($confirmation_code){
|
|
if( ! $confirmation_code)
|
|
{
|
|
return redirect('/status/error');
|
|
}
|
|
|
|
$user = User::whereConfirmationCode($confirmation_code)->first();
|
|
|
|
if ( ! $user)
|
|
{
|
|
|
|
// return redirect('/status/not/found');
|
|
return redirect('/home');
|
|
|
|
}
|
|
$user->confirmed = 1;
|
|
$user->confirmation_date = now();
|
|
// $user->confirmation_code = null;
|
|
// $user->confirmation_code_to = null;
|
|
// $user->confirmation_code_remider = 0;
|
|
$user->save();
|
|
|
|
//Login!
|
|
Auth::login($user);
|
|
|
|
return redirect('/home');
|
|
}
|
|
|
|
public function statusRegister(){
|
|
return view('status.status_register');
|
|
}
|
|
public function statusVerify(){
|
|
return view('status.status_verify');
|
|
}
|
|
public function statusError(){
|
|
return view('status.status_error');
|
|
}
|
|
public function notFound(){
|
|
return view('status.not_found');
|
|
}
|
|
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function checkMail(){
|
|
|
|
$data = Input::all();
|
|
if($data['user_id'] == "new"){
|
|
if(User::where('email', $data['email'])->count()){
|
|
return json_encode(false);
|
|
}
|
|
}else{
|
|
if(User::where('email', $data['email'])->where('id', '!=', $data['user_id'])->count()){
|
|
return json_encode(false);
|
|
}
|
|
}
|
|
return json_encode(true);
|
|
}
|
|
|
|
public function blocked()
|
|
{
|
|
return view('status.user_blocked');
|
|
}
|
|
|
|
public function backToShop($reference = ""){
|
|
|
|
if($reference){
|
|
$ShoppingPayment = ShoppingPayment::where('reference', $reference)->first();
|
|
if($ShoppingPayment->status == 'success'){
|
|
$user = Auth::user();
|
|
if($user->wizard < 4){
|
|
$user->wizard = 4;
|
|
$user->save();
|
|
return redirect(route('wizard', [4]));
|
|
}
|
|
|
|
}else{
|
|
\Session()->flash('alert-error', "Es ist ein Fehler bei der Bestellung aufgetreten");
|
|
return redirect(route('wizard'));
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|