Skip to content

Commit

Permalink
Auth::getUser() -> Auth::user()
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Aug 31, 2024
1 parent cae8643 commit 9d5da54
Show file tree
Hide file tree
Showing 29 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion classes/cart/DiscountApplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function productIsInCart(int $productId): bool

private function userBelongsToCustomerGroup(int $customerGroupId): bool
{
$group = optional(Auth::getUser())->customer_group();
$group = optional(Auth::user())->customer_group();

if (! $group) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion classes/customer/DefaultSignInHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function login(array $data)
// RainLab.User 3.0 compatibility
if (class_exists(Setting::class)) {
if (Auth::attempt(['email' => $credentials['login'], 'password' => $credentials['password']], true)) {
$user = Auth::getUser();
$user = Auth::user();
} else {
throw new AuthException('rainlab.user::lang.account.invalid_login');
}
Expand Down
4 changes: 2 additions & 2 deletions classes/downloads/VirtualProductFileDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(string $key)

// Redirect the user to the login page if a session is required but
// no user is logged in.
if ($product->file_session_required && ! Auth::getUser()) {
if ($product->file_session_required && ! Auth::user()) {
return $this->redirectToLogin();
}

Expand Down Expand Up @@ -69,7 +69,7 @@ public function handle(string $key)
// If no file is around, return and log an error. The site admin needs to fix this!
Log::error(
'[OFFLINE.Mall] A virtual product without a file attachment has been purchased. You need to fix this!',
['grant' => $grant, 'product' => $product, 'user' => Auth::getUser()]
['grant' => $grant, 'product' => $product, 'user' => Auth::user()]
);

return response($this->trans('not_found'), 500);
Expand Down
2 changes: 1 addition & 1 deletion classes/pricing/concerns/ApplyDiscounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function productIsInCart(int $id): bool
protected function userBelongsToCustomerGroup(int $id): bool
{
/** @ignore @disregard facade alias for \RainLab\User\Classes\AuthManager */
$group = optional(Auth::getUser())->customer_group();
$group = optional(Auth::user())->customer_group();

return $group ? $group->where('id', $id)->exists() : false;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/traits/FilteredTaxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getFilteredTaxes($taxes)
*/
public function getCartCountryId()
{
$cart = Cart::byUser(Auth::getUser());
$cart = Cart::byUser(Auth::user());

if (!$cart) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions classes/traits/UserSpecificPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait UserSpecificPrice
{
public function getUserSpecificPrice(Price $original)
{
$group = optional(Auth::getUser())->customer_group;
$group = optional(Auth::user())->customer_group;

if (! $this->hasUserSpecificPrice()) {
return $this->checkDiscount($group, $original);
Expand Down Expand Up @@ -51,7 +51,7 @@ protected function checkDiscount(?CustomerGroup $group, Price $original): ?Price
protected function hasUserSpecificPrice(): bool
{
return ! app()->runningInBackend()
&& optional(Auth::getUser())->offline_mall_customer_group_id !== null
&& optional(Auth::user())->offline_mall_customer_group_id !== null
&& $this->customer_group_prices->count() > 0;
}
}
2 changes: 1 addition & 1 deletion classes/traits/cart/Discounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function applyDiscount(Discount $discount, int $discountCodeLimit = 0)
}

$previousOrderDiscounts = collect();
$customer = optional(Auth::getUser())->customer;
$customer = optional(Auth::user())->customer;

if (optional($customer)->orders) {
$previousOrderDiscounts = $customer->orders->map(fn ($order) => array_get($order, 'discounts.0.discount.id'));
Expand Down
6 changes: 3 additions & 3 deletions components/AddressForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ public function getSetOptions()
*/
public function setData()
{
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return false;
}

$this->setVar('setAddressAs', $this->property('set'));
$this->setVar('cart', Cart::byUser(Auth::getUser()));
$this->setVar('cart', Cart::byUser(Auth::user()));
$this->setVar('countries', Country::getNameList());
$this->setVar('useState', GeneralSettings::get('use_state', true));

Expand Down Expand Up @@ -180,7 +180,7 @@ public function onRun()
public function onSubmit()
{
$this->setData();
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return $this->controller->run('404');
Expand Down
8 changes: 4 additions & 4 deletions components/AddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function defineProperties()
*/
public function init()
{
if ($user = Auth::getUser()) {
if ($user = Auth::user()) {
$this->addresses = $user->customer->addresses;
$this->defaultBillingAddressId = $user->customer->default_billing_address_id;
$this->defaultShippingAddressId = $user->customer->default_shipping_address_id;
Expand Down Expand Up @@ -128,7 +128,7 @@ public function onChangeDefaultBillingAddress()
public function updateDefaultAddressFromUser(string $type)
{
$id = $this->decode(post('id'));
$user = Auth::getUser();
$user = Auth::user();
$customer = $user->customer;
$cart = Cart::byUser($user);

Expand Down Expand Up @@ -160,7 +160,7 @@ public function updateDefaultAddressFromUser(string $type)
public function onDelete()
{
$id = $this->decode(post('id'));
$user = Auth::getUser();
$user = Auth::user();
$customer = $user->customer;
$cart = Cart::byUser($user);
$address = Address::byCustomer($customer)->where('id', $id)->first();
Expand All @@ -174,7 +174,7 @@ public function onDelete()
}

$address->delete();
$this->addresses = Auth::getUser()->load('customer')->customer->addresses;
$this->addresses = Auth::user()->load('customer')->customer->addresses;

$defaultAddress = Address::byCustomer($customer)->first();

Expand Down
10 changes: 5 additions & 5 deletions components/AddressSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getTypeOptions()
*/
public function init()
{
$user = Auth::getUser();
$user = Auth::user();
$this->setVar('cart', Cart::byUser($user));
}

Expand All @@ -130,7 +130,7 @@ public function onRun()
{
$this->setData();

if (Auth::getUser() && $this->addresses->count() < 1) {
if (Auth::user() && $this->addresses->count() < 1) {
Flash::warning(trans('offline.mall::frontend.flash.missing_address'));

$url = $this->controller->pageUrl($this->addressPage, [
Expand All @@ -152,7 +152,7 @@ public function onRun()
*/
public function onChangeAddress()
{
$user = Auth::getUser();
$user = Auth::user();
$this->setData();

$this->setVar('addresses', Address::byCustomer($user->customer)->get());
Expand All @@ -167,7 +167,7 @@ public function onChangeAddress()
*/
public function onUpdateAddress()
{
$user = Auth::getUser();
$user = Auth::user();
$this->setData();

$data = post();
Expand Down Expand Up @@ -208,7 +208,7 @@ public function onUpdateAddress()
*/
protected function setData()
{
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return;
Expand Down
8 changes: 4 additions & 4 deletions components/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function onRun()
*/
public function setData()
{
$cart = CartModel::byUser(Auth::getUser());
$cart = CartModel::byUser(Auth::user());
$cart->loadMissing(['products', 'products.custom_field_values', 'discounts']);

if ($cart->shipping_method_id === null) {
Expand All @@ -189,7 +189,7 @@ public function onUpdateQuantity()
{
$id = $this->decode(input('id'));

$cart = CartModel::byUser(Auth::getUser());
$cart = CartModel::byUser(Auth::user());
$product = $this->getProductFromCart($cart, $id);

if (!$product) {
Expand All @@ -216,7 +216,7 @@ public function onRemoveProduct()
{
$id = $this->decode(input('id'));

$cart = CartModel::byUser(Auth::getUser());
$cart = CartModel::byUser(Auth::user());

$product = $this->getProductFromCart($cart, $id);

Expand Down Expand Up @@ -246,7 +246,7 @@ public function onRemoveDiscountCode()
{
$id = $this->decode(input('id'));

$cart = CartModel::byUser(Auth::getUser());
$cart = CartModel::byUser(Auth::user());

$cart->removeDiscountCodeById($id);

Expand Down
2 changes: 1 addition & 1 deletion components/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function stepUrl($step, $params = [])
*/
protected function setData()
{
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return;
Expand Down
2 changes: 1 addition & 1 deletion components/CustomerProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function defineProperties()
public function init()
{
/** @ignore @disregard facade alias for \RainLab\User\Classes\AuthManager */
$this->user = Auth::getUser();
$this->user = Auth::user();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/DiscountApplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function defineProperties()
public function onApplyDiscount()
{
$code = strtoupper(post('code'));
$cart = Cart::byUser(Auth::getUser());
$cart = Cart::byUser(Auth::user());

try {
$cart->applyDiscountByCode($code, (int)$this->property('discountCodeLimit'));
Expand Down
4 changes: 2 additions & 2 deletions components/OrdersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function defineProperties()
*/
public function init()
{
$user = Auth::getUser();
$user = Auth::user();

if (!$user || !$user->customer) {
return;
Expand All @@ -81,7 +81,7 @@ public function init()

public function onCancelOrder()
{
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return;
Expand Down
2 changes: 1 addition & 1 deletion components/PaymentMethodSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function renderPaymentForm()
*/
protected function setData()
{
$user = Auth::getUser();
$user = Auth::user();

if (! $user) {
return;
Expand Down
2 changes: 1 addition & 1 deletion components/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ function (Variant $variant) {
*/
protected function addToCart(ProductModel $product, $quantity, $variant, $values, array $serviceOptions = [])
{
$cart = Cart::byUser(Auth::getUser());
$cart = Cart::byUser(Auth::user());

$serviceOptions = array_filter($serviceOptions);

Expand Down
8 changes: 4 additions & 4 deletions components/ProductReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function setData()
$this->accountPage = GeneralSettings::get('account_page');
$this->isModerated = ReviewSettings::get('moderated');

if (Auth::getUser()) {
if (Auth::user()) {
$this->canReview = true;
} else {
$this->canReview = ReviewSettings::get('allow_anonymous', false);
Expand All @@ -122,8 +122,8 @@ public function setData()
->when($this->property('variant'), function ($q) {
$q->where('variant_id', $this->property('variant'));
})
->when(optional(Auth::getUser())->customer, function ($q) {
$q->where('customer_id', Auth::getUser()->customer->id);
->when(optional(Auth::user())->customer, function ($q) {
$q->where('customer_id', Auth::user()->customer->id);
}, function ($q) {
$q->where('user_hash', Review::getUserHash());
})
Expand Down Expand Up @@ -162,7 +162,7 @@ public function onCreate()
$review->fill($data);
$review->product_id = $this->property('product');
$review->variant_id = $this->property('variant');
$review->customer_id = optional(optional(Auth::getUser())->customer)->id;
$review->customer_id = optional(optional(Auth::user())->customer)->id;

if (! $this->isModerated) {
$review->approved_at = now();
Expand Down
2 changes: 1 addition & 1 deletion components/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function onAddToCart()
->firstOrFail();
}

$cart = CartModel::byUser(Auth::getUser());
$cart = CartModel::byUser(Auth::user());
$quantity = (int)post('quantity', $product->quantity_default ?? 1);

if ($quantity < 1) {
Expand Down
10 changes: 5 additions & 5 deletions components/QuickCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function onRemoveProduct()
{
$id = $this->decode(input('id'));

$cart = Cart::byUser(FrontendAuth::getUser());
$cart = Cart::byUser(FrontendAuth::user());

$product = $this->getProductFromCart($cart, $id);

Expand All @@ -392,7 +392,7 @@ public function onRemoveDiscountCode()
{
$id = $this->decode(input('id'));

$cart = Cart::byUser(Auth::getUser());
$cart = Cart::byUser(Auth::user());

$cart->removeDiscountCodeById($id);

Expand Down Expand Up @@ -478,7 +478,7 @@ protected function setData()
$this->currentPage = $this->page->page->getBaseFileName();
$this->setVar('accountPage', GeneralSettings::get('account_page'));

$this->setVar('user', Auth::getUser());
$this->setVar('user', Auth::user());

$cart = Cart::byUser($this->user);

Expand Down Expand Up @@ -531,11 +531,11 @@ protected function setData()
*/
protected function getCustomerMethods()
{
if (! optional(Auth::getUser())->customer) {
if (! optional(Auth::user())->customer) {
return collect([]);
}

return optional(Auth::getUser()->customer->payment_methods)->groupBy('payment_method_id');
return optional(Auth::user()->customer->payment_methods)->groupBy('payment_method_id');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/ShippingMethodSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function onChangeMethod()
protected function setData()
{
$this->skipIfOnlyOneAvailable = (bool)$this->property('skipIfOnlyOneAvailable');
$this->setVar('cart', Cart::byUser(Auth::getUser()));
$this->setVar('cart', Cart::byUser(Auth::user()));
$this->setVar('methods', ShippingMethod::getAvailableByCart($this->cart));
$this->setVar('shippingSelectionBeforePayment', GeneralSettings::get('shipping_selection_before_payment', false)); // Needed by themes
}
Expand Down
Loading

0 comments on commit 9d5da54

Please sign in to comment.