Skip to content

Commit

Permalink
Merge pull request inertiajs#99 from inertiajs/upgrade
Browse files Browse the repository at this point in the history
Upgrade Ping CRM to latest version of Inertia.js
  • Loading branch information
reinink authored Feb 27, 2021
2 parents c3f0ab7 + 2e1d28c commit 8fe940c
Show file tree
Hide file tree
Showing 36 changed files with 5,640 additions and 4,994 deletions.
39 changes: 28 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:vue/recommended',
],
extends: ['eslint:recommended', 'plugin:vue/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
amd: true,
browser: true,
es6: true,
},
rules: {
"indent": ['error', 2],
'quotes': ['warn', 'single'],
'semi': ['warn', 'never'],
indent: ['error', 2],
quotes: ['warn', 'single'],
semi: ['warn', 'never'],
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
'comma-dangle': ['warn', 'always-multiline'],
'vue/max-attributes-per-line': false,
'vue/require-default-prop': false,
'vue/singleline-html-element-content-newline': false,
}
'vue/max-attributes-per-line': 'off',
'vue/require-default-prop': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/html-self-closing': [
'warn',
{
html: {
void: 'always',
normal: 'always',
component: 'always',
},
},
],
},
}
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 10000,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"htmlWhitespaceSensitivity": "css"
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function index()
->orderByName()
->filter(Request::only('search', 'trashed'))
->paginate()
->transform(function ($contact) {
->through(function ($contact) {
return [
'id' => $contact->id,
'name' => $contact->name,
Expand Down
10 changes: 9 additions & 1 deletion app/Http/Controllers/OrganizationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ public function index()
->orderBy('name')
->filter(Request::only('search', 'trashed'))
->paginate()
->only('id', 'name', 'phone', 'city', 'deleted_at'),
->through(function ($organization) {
return [
'id' => $organization->id,
'name' => $organization->name,
'phone' => $organization->phone,
'city' => $organization->city,
'deleted_at' => $organization->deleted_at,
];
}),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function share(Request $request)
'first_name' => $request->user()->first_name,
'last_name' => $request->user()->last_name,
'email' => $request->user()->email,
'role' => $request->user()->role,
'owner' => $request->user()->owner,
'account' => [
'id' => $request->user()->account->id,
'name' => $request->user()->account->name,
Expand Down
86 changes: 7 additions & 79 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace App\Providers;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\UrlWindow;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Glide\Server;
Expand All @@ -18,12 +14,6 @@ class AppServiceProvider extends ServiceProvider
* @return void
*/
public function register()
{
$this->registerGlide();
$this->registerLengthAwarePaginator();
}

protected function registerGlide()
{
$this->app->bind(Server::class, function ($app) {
return Server::create([
Expand All @@ -35,75 +25,13 @@ protected function registerGlide()
});
}

protected function registerLengthAwarePaginator()
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app->bind(LengthAwarePaginator::class, function ($app, $values) {
return new class(...array_values($values)) extends LengthAwarePaginator {
public function only(...$attributes)
{
return $this->transform(function ($item) use ($attributes) {
return $item->only($attributes);
});
}

public function transform($callback)
{
$this->items->transform($callback);

return $this;
}

public function toArray()
{
return [
'data' => $this->items->toArray(),
'links' => $this->links(),
];
}

public function links($view = null, $data = [])
{
$this->appends(Request::all());

$window = UrlWindow::make($this);

$elements = array_filter([
$window['first'],
is_array($window['slider']) ? '...' : null,
$window['slider'],
is_array($window['last']) ? '...' : null,
$window['last'],
]);

return Collection::make($elements)->flatMap(function ($item) {
if (is_array($item)) {
return Collection::make($item)->map(function ($url, $page) {
return [
'url' => $url,
'label' => $page,
'active' => $this->currentPage() === $page,
];
});
} else {
return [
[
'url' => null,
'label' => '...',
'active' => false,
],
];
}
})->prepend([
'url' => $this->previousPageUrl(),
'label' => 'Previous',
'active' => false,
])->push([
'url' => $this->nextPageUrl(),
'label' => 'Next',
'active' => false,
]);
}
};
});
//
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"license": "MIT",
"require": {
"php": "^7.3.0",
"php": "^7.3|^8.0",
"ext-exif": "*",
"ext-gd": "*",
"facade/ignition": "^2.3.6",
Expand Down
Loading

0 comments on commit 8fe940c

Please sign in to comment.