diff --git a/app/Http/Controllers/ContactsController.php b/app/Http/Controllers/ContactsController.php index d78eaf1..2402a34 100644 --- a/app/Http/Controllers/ContactsController.php +++ b/app/Http/Controllers/ContactsController.php @@ -20,7 +20,7 @@ class ContactsController extends Controller ->orderByName() ->filter(Request::only('search', 'trashed')) ->paginate() - ->transform(function ($contact) { + ->through(function ($contact) { return [ 'id' => $contact->id, 'name' => $contact->name, diff --git a/app/Http/Controllers/OrganizationsController.php b/app/Http/Controllers/OrganizationsController.php index 8a8e9c6..b641cd6 100644 --- a/app/Http/Controllers/OrganizationsController.php +++ b/app/Http/Controllers/OrganizationsController.php @@ -18,7 +18,15 @@ class OrganizationsController extends Controller ->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, + ]; + }), ]); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 9b591a2..62e7c2e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -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; @@ -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([ @@ -35,75 +25,13 @@ class AppServiceProvider extends ServiceProvider }); } - 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, - ]); - } - }; - }); + // } } diff --git a/resources/js/Pages/Contacts/Index.vue b/resources/js/Pages/Contacts/Index.vue index 5b5dfe4..6e373ce 100644 --- a/resources/js/Pages/Contacts/Index.vue +++ b/resources/js/Pages/Contacts/Index.vue @@ -58,7 +58,7 @@ - + diff --git a/resources/js/Pages/Organizations/Index.vue b/resources/js/Pages/Organizations/Index.vue index 238dd7b..c641f7f 100644 --- a/resources/js/Pages/Organizations/Index.vue +++ b/resources/js/Pages/Organizations/Index.vue @@ -50,7 +50,7 @@ - + diff --git a/resources/js/Shared/Pagination.vue b/resources/js/Shared/Pagination.vue index e85cc46..033d0c0 100644 --- a/resources/js/Shared/Pagination.vue +++ b/resources/js/Shared/Pagination.vue @@ -1,9 +1,11 @@