mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
php cs fixer tweak
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
.env
|
||||
.env.backup
|
||||
.env.testing
|
||||
.php-cs-fixer.cache
|
||||
.phpunit.result.cache
|
||||
.phpstorm.meta.php
|
||||
.vscode/
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -16,6 +16,9 @@ $config = new PhpCsFixer\Config();
|
||||
|
||||
return $config->setRules([
|
||||
'@PSR2' => true,
|
||||
'nullable_type_declaration_for_default_null_value' => [
|
||||
'use_nullable_type_declaration' => true
|
||||
],
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short'
|
||||
],
|
||||
@@ -35,6 +38,7 @@ return $config->setRules([
|
||||
'cast_spaces' => [
|
||||
'space' => 'single'
|
||||
],
|
||||
'use_arrow_functions' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'single_space_after_construct' => true,
|
||||
@@ -71,5 +75,6 @@ return $config->setRules([
|
||||
'constant_case' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'lowercase_static_reference' => true,
|
||||
'lambda_not_used_import' => true,
|
||||
])
|
||||
->setFinder($finder);
|
||||
|
||||
@@ -11,6 +11,4 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||
return (int) $user->id === (int) $id;
|
||||
});
|
||||
Broadcast::channel('App.User.{id}', fn ($user, $id) => (int) $user->id === (int) $id);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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']] : [];
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -430,7 +430,7 @@ class BrowseTest extends TestCase
|
||||
});
|
||||
|
||||
collect([$folder, $file])
|
||||
->each(function ($item) use ($user) {
|
||||
->each(function ($item) {
|
||||
$this->getJson('/api/browse/share')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
|
||||
Reference in New Issue
Block a user