php cs fixer tweak

This commit is contained in:
Peter Papp
2021-07-23 10:50:29 +02:00
parent d190eeb46d
commit 8951ebc69f
15 changed files with 70 additions and 105 deletions
+1 -3
View File
@@ -25,8 +25,6 @@ class AuthServiceProvider extends ServiceProvider
$this->registerPolicies();
// Define admin maintenance gate
Gate::define('maintenance', function ($user) {
return $user->role === 'admin';
});
Gate::define('maintenance', fn ($user) => $user->role === 'admin');
}
}
+2 -6
View File
@@ -32,12 +32,8 @@ class FortifyServiceProvider extends ServiceProvider
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
RateLimiter::for('login', function (Request $request) {
return Limit::perMinute(20)->by($request->email.$request->ip());
});
RateLimiter::for('login', fn (Request $request) => Limit::perMinute(20)->by($request->email.$request->ip()));
RateLimiter::for('two-factor', function (Request $request) {
return Limit::perMinute(5)->by($request->session()->get('login.id'));
});
RateLimiter::for('two-factor', fn (Request $request) => Limit::perMinute(5)->by($request->session()->get('login.id')));
}
}
+1 -3
View File
@@ -114,9 +114,7 @@ class User extends Authenticatable implements MustVerifyEmail
public function getUsedCapacityAttribute(): int
{
return $this->filesWithTrashed
->map(function ($item) {
return $item->getRawOriginal();
})->sum('filesize');
->map(fn ($item) => $item->getRawOriginal())->sum('filesize');
}
/**
@@ -21,35 +21,25 @@ class UserStorageResource extends JsonResource
// Get all images
$images = File::where('user_id', $this->id)
->where('type', 'image')->get()->map(function ($item) {
return (int) $item->getRawOriginal('filesize');
})->sum();
->where('type', 'image')->get()->map(fn ($item) => (int) $item->getRawOriginal('filesize'))->sum();
// Get all audios
$audios = File::where('user_id', $this->id)
->where('type', 'audio')->get()->map(function ($item) {
return (int) $item->getRawOriginal('filesize');
})->sum();
->where('type', 'audio')->get()->map(fn ($item) => (int) $item->getRawOriginal('filesize'))->sum();
// Get all videos
$videos = File::where('user_id', $this->id)
->where('type', 'video')->get()->map(function ($item) {
return (int) $item->getRawOriginal('filesize');
})->sum();
->where('type', 'video')->get()->map(fn ($item) => (int) $item->getRawOriginal('filesize'))->sum();
// Get all documents
$documents = File::where('user_id', $this->id)
->whereIn('mimetype', $document_mimetypes)->get()->map(function ($item) {
return (int) $item->getRawOriginal('filesize');
})->sum();
->whereIn('mimetype', $document_mimetypes)->get()->map(fn ($item) => (int) $item->getRawOriginal('filesize'))->sum();
// Get all other files
$others = File::where('user_id', $this->id)
->whereNotIn('mimetype', $document_mimetypes)
->whereNotIn('type', ['audio', 'video', 'image'])
->get()->map(function ($item) {
return (int) $item->getRawOriginal('filesize');
})->sum();
->get()->map(fn ($item) => (int) $item->getRawOriginal('filesize'))->sum();
return [
'data' => [
@@ -48,14 +48,10 @@ class PaymentMethodsController extends Controller
// filter payment methods without default payment
$paymentMethodsMapped = Cache::rememberForever($slug_payment_methods, function () use ($defaultPaymentMethod, $user) {
$paymentMethods = $user->paymentMethods()->filter(function ($paymentMethod) use ($defaultPaymentMethod) {
return $paymentMethod->id !== $defaultPaymentMethod->id;
});
$paymentMethods = $user->paymentMethods()->filter(fn ($paymentMethod) => $paymentMethod->id !== $defaultPaymentMethod->id);
// Get payment methods
return $paymentMethods->map(function ($paymentMethod) {
return $paymentMethod->asStripePaymentMethod();
})->values()->all();
return $paymentMethods->map(fn ($paymentMethod) => $paymentMethod->asStripePaymentMethod())->values()->all();
});
}
@@ -13,9 +13,7 @@ class ActivePlansController
public function __invoke(): PricingCollection
{
// Get pricing from cache
$pricing = Cache::rememberForever('pricing', function () {
return resolve(StripeService::class)->getActivePlans();
});
$pricing = Cache::rememberForever('pricing', fn () => resolve(StripeService::class)->getActivePlans());
// Format pricing to collection
$collection = new PricingCollection($pricing);
@@ -22,9 +22,7 @@ class PlansController extends Controller
{
// Store or Get plans to cache
$plans = cache()
->rememberForever('plans', function () {
return $this->stripe->getPlans();
});
->rememberForever('plans', fn () => $this->stripe->getPlans());
return response(new PlanCollection($plans), 200);
}
@@ -36,9 +34,7 @@ class PlansController extends Controller
{
// Store or Get plan to cache
$plan = cache()
->rememberForever("plan-$id", function () use ($id) {
return $this->stripe->getPlan($id);
});
->rememberForever("plan-$id", fn () => $this->stripe->getPlan($id));
return response(new PlanResource($plan), 200);
}
@@ -51,9 +47,7 @@ class PlansController extends Controller
{
if (is_demo()) {
$plan = cache()
->rememberForever('plan-starter-pack', function () {
return $this->stripe->getPlan('starter-pack');
});
->rememberForever('plan-starter-pack', fn () => $this->stripe->getPlan('starter-pack'));
return new PlanResource($plan);
}
@@ -21,9 +21,7 @@ class StripeWebhookController extends CashierController
public function handleCustomerSubscriptionDeleted($payload)
{
if ($user = $this->getUserByStripeId($payload['data']['object']['customer'])) {
$user->subscriptions->filter(function ($subscription) use ($payload) {
return $subscription->stripe_id === $payload['data']['object']['id'];
})->each(function ($subscription) {
$user->subscriptions->filter(fn ($subscription) => $subscription->stripe_id === $payload['data']['object']['id'])->each(function ($subscription) {
$subscription->markAsCancelled();
});
}
@@ -17,9 +17,7 @@ trait Subscription
);
// Find tax rate
$user_tax_rate = $rates->first(function ($item) {
return $item['country'] === $this->settings->country && $item['active'];
});
$user_tax_rate = $rates->first(fn ($item) => $item['country'] === $this->settings->country && $item['active']);
return $user_tax_rate ? [$user_tax_rate['id']] : [];
}
+2 -6
View File
@@ -596,9 +596,7 @@ if (! function_exists('map_language_translations')) {
*/
function map_language_translations($translations): Collection
{
return $translations->map(function ($string) {
return [$string->key => $string->value];
})->collapse();
return $translations->map(fn ($string) => [$string->key => $string->value])->collapse();
}
}
@@ -904,9 +902,7 @@ if (! function_exists('get_files_for_zip')) {
// Get all children folders and folders within
if ($folders->folders->isNotEmpty()) {
$folders->folders->map(function ($folder) use ($files, $path) {
return get_files_for_zip($folder, $files, $path);
});
$folders->folders->map(fn ($folder) => get_files_for_zip($folder, $files, $path));
}
return get_files_for_zip($folders->folders->first(), $files, $path);