Filters collapsed, customer auth and register, fix on basket recalculation
This commit is contained in:
@@ -7,64 +7,39 @@ use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Repositories\Layout;
|
||||
use App\Repositories\Languages;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
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 = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
$data['url'] = route('Shop.login.post');
|
||||
return view('Shop.auth.login', $data);
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('guest');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'username' => 'required|email',
|
||||
'password' => 'required|min:8'
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8',
|
||||
]);
|
||||
|
||||
if (Auth::guard('guest')->attempt(['username' => $request->username, 'password' => $request->password], $request->get('remember'))) {
|
||||
if (Auth::guard('customer')->attempt(['email' => $request->email, 'password' => $request->password], $request->get('remember'))) {
|
||||
return redirect()->intended(route('home'));
|
||||
}
|
||||
return back()->withInput($request->only('username', 'remember'));
|
||||
return back()->withInput($request->only('email', 'remember'));
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
|
||||
@@ -16,114 +16,52 @@ 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;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo;
|
||||
|
||||
/**
|
||||
* Is registering the first user ?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $firstUser;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
protected function guard()
|
||||
{
|
||||
$userModel = config('auth.providers.users.model');
|
||||
$this->firstUser = $userModel::whereRoleIs('admin')->count() === 0;
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return route where to redirect after login success.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
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, [
|
||||
'last_name' => 'required|max:255',
|
||||
'first_name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users,email,NULL,id,deleted_at,NULL',
|
||||
'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL',
|
||||
'password' => ['required', 'confirmed', new Password()],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application registration form.
|
||||
*
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
if (! $this->firstUser && ! config('boilerplate.auth.register')) {
|
||||
abort('404');
|
||||
}
|
||||
|
||||
return view('boilerplate::auth.register', ['firstUser' => $this->firstUser]);
|
||||
return view('Shop.auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
if (! $this->firstUser && ! config('boilerplate.auth.register')) {
|
||||
abort('404');
|
||||
}
|
||||
|
||||
$userModel = config('auth.providers.users.model');
|
||||
$roleModel = config('laratrust.models.role');
|
||||
|
||||
$user = $userModel::withTrashed()->updateOrCreate(['email' => $data['email']], [
|
||||
$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']),
|
||||
'last_login' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
if ($this->firstUser) {
|
||||
$admin = $roleModel::whereName('admin')->first();
|
||||
$user->attachRole($admin);
|
||||
} else {
|
||||
$user->restore();
|
||||
$role = $roleModel::whereName(config('boilerplate.auth.register_role'))->first();
|
||||
$user->roles()->sync([$role->id]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show message to verify e-mail.
|
||||
*
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
public function emailVerify()
|
||||
{
|
||||
if (Auth::user()->hasVerifiedEmail()) {
|
||||
@@ -133,25 +71,12 @@ class RegisterController extends Controller
|
||||
return view('boilerplate::auth.verify-email');
|
||||
}
|
||||
|
||||
/**
|
||||
* If e-mail has been verified, redirect to the given route.
|
||||
*
|
||||
* @param EmailVerificationRequest $request
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
*/
|
||||
public function emailVerifyRequest(EmailVerificationRequest $request)
|
||||
{
|
||||
$request->fulfill();
|
||||
|
||||
return redirect(route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send verification e-mail.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function emailSendVerification(Request $request)
|
||||
{
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
@@ -8,31 +8,10 @@ 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 = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
|
||||
@@ -18,12 +18,14 @@ class CategoryController extends Controller
|
||||
return $dataTable->render('Shop.Categories.list');
|
||||
}
|
||||
|
||||
public function show(Request $request, $category_id)
|
||||
public function show($category_id, $by_rows = false)
|
||||
{
|
||||
$data = self::init();
|
||||
$data['display_by_rows'] = $request->input('by_rows') ?? false;
|
||||
$data['display_by_rows'] = $by_rows;
|
||||
$data['category'] = Categories::getFull($category_id);
|
||||
$data['articles'] = Articles::getArticlesToSell(['category_id' => $category_id]);
|
||||
// dump($data['articles']);
|
||||
// exit;
|
||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||
return view('Shop.shelve', $data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user