-
app/Providers/AppServiceProvider.php
Open in GitHubuse Illuminate\Support\ServiceProvider; use Illuminate\Pagination\Paginator; use Illuminate\Support\Collection; use Illuminate\Pagination\LengthAwarePaginator; class AppServiceProvider extends ServiceProvider { // public function boot() { // Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') { $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); return new LengthAwarePaginator( $this->forPage($page, $perPage), $total ?: $this->count(), $perPage, $page, [ 'path' => LengthAwarePaginator::resolveCurrentPath(), 'pageName' => $pageName, ] ); }); } }
-
app/Http/Controllers/CategoriesController.php
Open in GitHubuse App\Helpers\Categories\CategoriesHandler; use App\Helpers\User\UserHandler; use App\Helpers\Theme\Theme; class CategoriesController extends Controller { public function showCast($slug) { $movies = CategoriesHandler::getMovieByCategory('cast', $slug); $series = CategoriesHandler::getSeriesByCategory('cast', $slug); $results = []; foreach($movies as $movie) $results[] = $movie; foreach($series as $s) $results[] = $s; shuffle($results); $results = collect($results)->paginate(9); $subscribed = UserHandler::checkSubscription(); return Theme::view('categories.cast', [ 'content' => $results, 'subscribed' => $subscribed, 'cast' => $slug, ]); } }