restart
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
@@ -26,7 +26,7 @@ class ConfirmPasswordController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '';
|
||||
protected $redirectTo = '/admin';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
38
app/Http/Controllers/Admin/Auth/ForgotPasswordController.php
Normal file
38
app/Http/Controllers/Admin/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\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');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
return view('auth.passwords.email', $data);
|
||||
}
|
||||
}
|
||||
35
app/Http/Controllers/Admin/Auth/LoginController.php
Normal file
35
app/Http/Controllers/Admin/Auth/LoginController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
protected $redirectTo = '/admin';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('guest:web')->except('logout');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
public function authenticated(Request $request, $user)
|
||||
{
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'username';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
76
app/Http/Controllers/Admin/Auth/RegisterController.php
Normal file
76
app/Http/Controllers/Admin/Auth/RegisterController.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
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 = '/admin';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
47
app/Http/Controllers/Admin/Auth/ResetPasswordController.php
Normal file
47
app/Http/Controllers/Admin/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
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');
|
||||
}
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$data['token'] = $token;
|
||||
$data['email'] = $request->email;
|
||||
return view('auth.passwords.reset', $data);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
namespace App\Http\Controllers\Admin\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
@@ -25,7 +25,7 @@ class VerificationController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
@@ -20,12 +20,6 @@ class OrderController extends Controller
|
||||
return view('Admin.Shop.Orders.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = Orders::store($request->all());
|
||||
return redirect()->route('Admin.Shop.Orders.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = Orders::get($id);
|
||||
@@ -34,14 +28,20 @@ class OrderController extends Controller
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['order'] = Orders::get($id, ['customer', 'detail'])->toArray();
|
||||
dump($data['order']);
|
||||
exit;
|
||||
$data['order'] = Orders::edit($id)->toArray();
|
||||
// dump($data);
|
||||
// exit;
|
||||
return view('Admin.Shop.Orders.edit', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = Orders::store($request->all());
|
||||
return redirect()->route('Admin.Shop.Orders.index');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
return Orders::destroy($id);
|
||||
return Orders::delete($id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,36 +3,27 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
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()
|
||||
protected function guard()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
$data = \App\Repositories\Config::init();
|
||||
return view('auth.passwords.email', $data);
|
||||
return view('Shop.auth.passwords.email');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,26 +10,48 @@ use Illuminate\Http\Request;
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
protected $redirectTo = '/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('guest:web')->except('logout');
|
||||
// $this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('auth.login', $data ?? []);
|
||||
return view('Shop.auth.login');
|
||||
}
|
||||
|
||||
public function authenticated(Request $request, $user)
|
||||
public function login(Request $request)
|
||||
{
|
||||
return redirect()->intended($this->redirectPath());
|
||||
$credentials = $request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8',
|
||||
]);
|
||||
|
||||
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
|
||||
$request->session()->regenerate();
|
||||
return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back();
|
||||
}
|
||||
return back()->withInput($request->only('email', 'remember'));
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$sessionKey = $this->guard()->getName();
|
||||
$this->guard()->logout();
|
||||
$request->session()->forget($sessionKey);
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'username';
|
||||
return 'email';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,75 +2,84 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Sebastienheyd\Boilerplate\Rules\Password;
|
||||
|
||||
use App\Models\Shop\Customer;
|
||||
|
||||
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';
|
||||
protected $redirectTo;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
protected function guard()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
protected function redirectTo()
|
||||
{
|
||||
return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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',
|
||||
]
|
||||
);
|
||||
return Validator::make($data, [
|
||||
'last_name' => 'required|max:255',
|
||||
'first_name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL',
|
||||
'password' => ['required', 'confirmed', new Password()],
|
||||
]);
|
||||
}
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
return view('Shop.auth.register', $data ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']),
|
||||
]
|
||||
);
|
||||
$user = Customer::withTrashed()->updateOrCreate(['email' => $data['email']], [
|
||||
'active' => true,
|
||||
'first_name' => $data['first_name'],
|
||||
'last_name' => $data['last_name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function emailVerify()
|
||||
{
|
||||
if (Auth::user()->hasVerifiedEmail()) {
|
||||
return redirect(route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')));
|
||||
}
|
||||
|
||||
return view('boilerplate::auth.verify-email');
|
||||
}
|
||||
|
||||
public function emailVerifyRequest(EmailVerificationRequest $request)
|
||||
{
|
||||
$request->fulfill();
|
||||
return redirect(route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')));
|
||||
}
|
||||
|
||||
public function emailSendVerification(Request $request)
|
||||
{
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
return back()->with('message', 'Verification link sent!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use App\Rules\Password as PasswordRules;
|
||||
|
||||
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';
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
@@ -40,8 +22,29 @@ class ResetPasswordController extends Controller
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$data['token'] = $token;
|
||||
$data['email'] = $request->email;
|
||||
return view('auth.passwords.reset', $data);
|
||||
$token = $request->route()->parameter('token');
|
||||
|
||||
return view('Shop.auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
);
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'token' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => ['required', 'confirmed', new PasswordRules()],
|
||||
];
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class VerificationController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
||||
@@ -9,7 +9,6 @@ use App\Repositories\Shop\Articles;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data['article'] = Articles::getArticleToSell($id);
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('Shop.auth.passwords.email');
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
use AuthenticatesUsers;
|
||||
|
||||
protected $redirectTo = '/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('Shop.auth.login');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8',
|
||||
]);
|
||||
|
||||
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
|
||||
$request->session()->regenerate();
|
||||
return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back();
|
||||
}
|
||||
return back()->withInput($request->only('email', 'remember'));
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$sessionKey = $this->guard()->getName();
|
||||
$this->guard()->logout();
|
||||
$request->session()->forget($sessionKey);
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'email';
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Sebastienheyd\Boilerplate\Rules\Password;
|
||||
|
||||
use App\Models\Shop\Customer;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
use RegistersUsers;
|
||||
|
||||
protected $redirectTo;
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
protected function redirectTo()
|
||||
{
|
||||
return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
|
||||
}
|
||||
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'last_name' => 'required|max:255',
|
||||
'first_name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL',
|
||||
'password' => ['required', 'confirmed', new Password()],
|
||||
]);
|
||||
}
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
return view('Shop.auth.register', $data ?? []);
|
||||
}
|
||||
|
||||
protected function create(array $data)
|
||||
{
|
||||
$user = Customer::withTrashed()->updateOrCreate(['email' => $data['email']], [
|
||||
'active' => true,
|
||||
'first_name' => $data['first_name'],
|
||||
'last_name' => $data['last_name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function emailVerify()
|
||||
{
|
||||
if (Auth::user()->hasVerifiedEmail()) {
|
||||
return redirect(route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')));
|
||||
}
|
||||
|
||||
return view('boilerplate::auth.verify-email');
|
||||
}
|
||||
|
||||
public function emailVerifyRequest(EmailVerificationRequest $request)
|
||||
{
|
||||
$request->fulfill();
|
||||
return redirect(route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')));
|
||||
}
|
||||
|
||||
public function emailSendVerification(Request $request)
|
||||
{
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
return back()->with('message', 'Verification link sent!');
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use App\Rules\Password as PasswordRules;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
use ResetsPasswords;
|
||||
|
||||
protected $redirectTo = '/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$token = $request->route()->parameter('token');
|
||||
|
||||
return view('Shop.auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
);
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'token' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => ['required', 'confirmed', new PasswordRules()],
|
||||
];
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class CustomerController extends Controller
|
||||
{
|
||||
public function profile($id = false)
|
||||
{
|
||||
return view('Shop.Customers.profile');
|
||||
$data = Customers::editProfile($id);
|
||||
return view('Shop.Customers.profile', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Repositories\Shop\Deliveries;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use App\Repositories\Shop\Paybox;
|
||||
use App\Repositories\Shop\Baskets;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
|
||||
@@ -30,13 +31,13 @@ class OrderController extends Controller
|
||||
{
|
||||
$data = $request->all();
|
||||
$data['customer_id'] = Customers::getId();
|
||||
$data['basket'] = Baskets::getBasketSummary();
|
||||
dump($data);
|
||||
exit;
|
||||
$data['sale_channel_id'] = $data['sale_channel_id'] ?? SaleChannels::getDefaultID();
|
||||
$data['basket'] = Baskets::getBasketSummary($data['sale_channel_id']);
|
||||
$order = Orders::saveOrder($data);
|
||||
if ($order) {
|
||||
if ($data['payment'] == '1') {
|
||||
return redirect()->route('Shop.Payments.online');
|
||||
if ($data['payment_type'] == '1') {
|
||||
return Paybox::makeAuthorizationRequest($data['basket']['total_shipped']);
|
||||
// return redirect()->route('Shop.Payments.online');
|
||||
} else {
|
||||
return redirect()->route('Shop.Orders.confirmed');
|
||||
}
|
||||
@@ -47,6 +48,7 @@ class OrderController extends Controller
|
||||
|
||||
public function confirmed()
|
||||
{
|
||||
ShopCart::clear();
|
||||
return view('Shop.Orders.confirmed');
|
||||
}
|
||||
}
|
||||
|
||||
18
app/Http/Controllers/Shop/OrderPaymentController.php
Normal file
18
app/Http/Controllers/Shop/OrderPaymentController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use App\Repositories\Shop\Deliveries;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use App\Repositories\Shop\Paybox;
|
||||
use App\Repositories\Shop\Baskets;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
|
||||
class OrderPaymentController extends Controller
|
||||
{
|
||||
}
|
||||
36
app/Http/Controllers/Shop/PayboxController.php
Normal file
36
app/Http/Controllers/Shop/PayboxController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class PayboxController extends Controller
|
||||
{
|
||||
public function accepted()
|
||||
{
|
||||
return view('paybox.accepted');
|
||||
}
|
||||
|
||||
public function refused()
|
||||
{
|
||||
return view('paybox.refused');
|
||||
}
|
||||
|
||||
public function aborted()
|
||||
{
|
||||
return view('paybox.aborted');
|
||||
}
|
||||
|
||||
public function waiting()
|
||||
{
|
||||
return view('paybox.waiting');
|
||||
}
|
||||
|
||||
public function process(Request $request)
|
||||
{
|
||||
dump($request);
|
||||
return view('paybox.send');
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use App\Notifications\NewUser;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
use App\Repositories\Core\DateTime;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
|
||||
@@ -579,4 +579,15 @@ class Articles
|
||||
{
|
||||
return self::update(['homepage' => $homepage], $id);
|
||||
}
|
||||
|
||||
public static function getNumericHash($id)
|
||||
{
|
||||
return hexdec(self::getHash($id));
|
||||
}
|
||||
|
||||
public static function getHash($id)
|
||||
{
|
||||
$name = self::get($id)->name ?? false;
|
||||
return $name ? hash('crc32c', Str::slug($name)) : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,39 +16,44 @@ class Baskets
|
||||
return $data ? ShopCart::add($data, $update) : false;
|
||||
}
|
||||
|
||||
public static function getBasketSummary()
|
||||
public static function getBasketSummary($sale_channel_id = false)
|
||||
{
|
||||
$basket = ShopCart::getContent();
|
||||
$offers = Offer::with('variation')->whereIn('id', ShopCart::keys())->get();
|
||||
$total = 0;
|
||||
$total_taxed = 0;
|
||||
$shipping = 5;
|
||||
foreach ($basket as $item) {
|
||||
$offer = $offers->where('id', $item->id)->first();
|
||||
$prices = Offers::getPrice($item->id, $item->quantity, $sale_channel_id);
|
||||
$detail[] = [
|
||||
'id' => (int) $item->id,
|
||||
'offer_id' => (int) $item->id,
|
||||
'name' => $offer->article->name . ' (' . $offer->variation->name . ')',
|
||||
'quantity' => (int) $item->quantity,
|
||||
'price' => $item->price,
|
||||
'tax' => '',
|
||||
'price_taxed' => $item->price,
|
||||
'total' => self::getTotal($item->quantity, $item->price),
|
||||
'total_taxed' => self::getTotal($item->quantity, $item->price),
|
||||
'price' => (float) $prices->price,
|
||||
'tax' => $prices->price_taxed - $prices->price,
|
||||
'price_taxed' => (float) $prices->price_taxed,
|
||||
'total' => self::getTotal($item->quantity, $prices->price),
|
||||
'total_tax' => self::getTotal($item->quantity, $prices->price_taxed - $prices->price),
|
||||
'total_taxed' => self::getTotal($item->quantity, $prices->price_taxed),
|
||||
];
|
||||
$total += self::getTotal($item->quantity, $item->price);
|
||||
$total_taxed += self::getTotal($item->quantity, $item->price);
|
||||
$total += self::getTotal($item->quantity, $prices->price);
|
||||
$total_taxed += self::getTotal($item->quantity, $prices->price_taxed);
|
||||
}
|
||||
$data = [
|
||||
'detail' => $detail,
|
||||
'total' => $total,
|
||||
'taxes' => $total_taxed - $total,
|
||||
'total_taxed' => $total_taxed,
|
||||
'shipping' => $shipping,
|
||||
'total_shipped' => $total_taxed + $shipping,
|
||||
];
|
||||
return $data ?? false;
|
||||
}
|
||||
|
||||
public static function getTotal($quantity, $price)
|
||||
{
|
||||
return (int) $quantity * $price;
|
||||
return $quantity * $price;
|
||||
}
|
||||
|
||||
public static function getBasket($sale_channel_id = false)
|
||||
|
||||
@@ -4,9 +4,10 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use Spatie\Stats\BaseStats;
|
||||
|
||||
class CustomerStats extends BaseStats {}
|
||||
class CustomerStats extends BaseStats
|
||||
{
|
||||
public function getName() : string{
|
||||
public function getName() : string
|
||||
{
|
||||
return 'customers';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,16 @@ use App\Models\Shop\Customer;
|
||||
|
||||
class Customers
|
||||
{
|
||||
public static function editProfile($id = false)
|
||||
{
|
||||
$id = $id ? $id : self::getId();
|
||||
$data = [
|
||||
'customer' => self::get($id, ['addresses', 'deliveries', 'orders'])->toArray(),
|
||||
'deliveries' => Deliveries::getAll('sale_channel')->toArray(),
|
||||
];
|
||||
dump($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getAvatar($id = false)
|
||||
{
|
||||
|
||||
@@ -11,9 +11,10 @@ class Deliveries
|
||||
return Delivery::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
public static function getAll($relations = false)
|
||||
{
|
||||
return Delivery::orderBy('name', 'asc')->get();
|
||||
$model = $relations ? Delivery::with($relations) : Delivery::query();
|
||||
return $model->orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAllWithSaleChannel()
|
||||
|
||||
@@ -4,9 +4,10 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use Spatie\Stats\BaseStats;
|
||||
|
||||
class InvoiceStats extends BaseStats {}
|
||||
class InvoiceStats extends BaseStats
|
||||
{
|
||||
public function getName() : string{
|
||||
public function getName() : string
|
||||
{
|
||||
return 'invoices';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,9 @@ use App\Models\Shop\Invoice;
|
||||
|
||||
class Invoices
|
||||
{
|
||||
|
||||
public static function saveInvoice($order_id, $data)
|
||||
{
|
||||
$data['order_id'] = $order_id;
|
||||
dump($data);
|
||||
exit;
|
||||
return self::store($data);
|
||||
}
|
||||
|
||||
@@ -29,6 +26,7 @@ class Invoices
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
InvoiceStats::increase($data['total_taxed']);
|
||||
$data['uuid'] = Str::uuid()->toString();
|
||||
$data['ref'] = self::getNewRef();
|
||||
return Invoice::create($data);
|
||||
@@ -44,6 +42,8 @@ class Invoices
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
$invoice = self::get($id);
|
||||
InvoiceStats::decrease($invoice->total_priced);
|
||||
return Invoice::destroy($id);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ class Invoices
|
||||
{
|
||||
$ref = date('ym') . '00000';
|
||||
$last_ref = Invoice::orderBy('ref', 'desc')->where('ref', '>', $ref)->first();
|
||||
return $last_ref ? $last_ref + 1 : $ref + 1;
|
||||
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,8 @@ class OrderDetails
|
||||
public static function saveBasket($order_id, $data)
|
||||
{
|
||||
foreach ($data as $item) {
|
||||
$detail = self::store([
|
||||
'order_id' => $order_id,
|
||||
'offer_id' => $item['id'],
|
||||
'quantity' => $item['quantity'],
|
||||
'price_taxed' => $item['price'],
|
||||
]);
|
||||
$item['order_id'] = $order_id;
|
||||
$detail = self::store($item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
13
app/Repositories/Shop/OrderStats.php
Normal file
13
app/Repositories/Shop/OrderStats.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Spatie\Stats\BaseStats;
|
||||
|
||||
class OrderStats extends BaseStats
|
||||
{
|
||||
public function getName() : string
|
||||
{
|
||||
return 'orders';
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,24 @@ class Orders
|
||||
|
||||
public static function saveOrder($data)
|
||||
{
|
||||
$data += $data['basket'];
|
||||
$basket = $data['basket'];
|
||||
unset($data['basket']);
|
||||
dump($data);
|
||||
exit;
|
||||
$order = self::store($data);
|
||||
$invoice = Invoices::saveInvoice($order->id, $data);
|
||||
return $order ? OrderDetails::saveBasket($order->id, $basket) : false;
|
||||
$detail = OrderDetails::saveBasket($order->id, $basket['detail']);
|
||||
unset($data['comment']);
|
||||
unset($data['agree']);
|
||||
unset($data['customer_id']);
|
||||
unset($data['delivery_id']);
|
||||
unset($data['detail']);
|
||||
unset($data['payment_type']);
|
||||
unset($data['sale_channel_id']);
|
||||
return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false;
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
return Orders::get($id, ['customer', 'address', 'delivery', 'detail']);
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false)
|
||||
@@ -30,6 +41,7 @@ class Orders
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
OrderStats::increase();
|
||||
return Order::create($data);
|
||||
}
|
||||
|
||||
|
||||
53
app/Repositories/Shop/Paybox.php
Normal file
53
app/Repositories/Shop/Paybox.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App;
|
||||
|
||||
use Devpark\PayboxGateway\Requests\AuthorizationWithCapture;
|
||||
use Devpark\PayboxGateway\Responses\Verify;
|
||||
use Devpark\PayboxGateway\Requests\Capture;
|
||||
|
||||
class Paybox
|
||||
{
|
||||
|
||||
public static function makeAuthorizationRequest($amount, $customer_email = 'test@example.com')
|
||||
{
|
||||
$authorizationRequest = App::make(AuthorizationWithCapture::class);
|
||||
|
||||
return $authorizationRequest->setAmount($amount)->setCustomerEmail($customer_email)
|
||||
->setPaymentNumber(1)->send('paybox.send');
|
||||
}
|
||||
|
||||
public static function verifyPayment($invoice_id)
|
||||
{
|
||||
$invoice = Invoices::get($invoice_id);
|
||||
$payboxVerify = App::make(Verify::class);
|
||||
try {
|
||||
$success = $payboxVerify->isSuccess($invoice->total_shipped);
|
||||
if ($success) {
|
||||
// process order here after making sure it was real payment
|
||||
}
|
||||
echo "OK";
|
||||
}
|
||||
catch (InvalidSignature $e) {
|
||||
Log::alert('Invalid payment signature detected');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPreviousAuthorizedRequest()
|
||||
{
|
||||
$payment = PaymentModel::find($idOfAuthorizedPayment);
|
||||
$captureRequest = App::make(Capture::class);
|
||||
$response = $captureRequest->setAmount($payment->amount)
|
||||
->setPayboxCallNumber($payment->call_number)
|
||||
->setPayboxTransactionNumber($payment->transaction_number)
|
||||
->setDayRequestNumber(2)
|
||||
->send();
|
||||
|
||||
if ($response->isSuccess()) {
|
||||
// process order here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user