The Blog

Laravel

Laravel

Laravel Paginator Pretty URLs

John Koster
John Koster
July 28, 2014

Learn how to create pretty pagination URLs with Laravel's paginator in this step-by-step tutorial. By extending the Paginator class and overriding the getUrl() method, you can generate URLs like http://localhost:8000/users/page/1 instead of http://localhost:8000/users?page=1. The tutorial includes code examples and explains how to create a custom PrettyPaginator class and use it in your application. Keep in mind that there might be a package available to accomplish this task, so proceed with caution.

Laravel

Part Two: Creating a Custom Pagination View in Laravel

John Koster
John Koster
July 28, 2014

Learn how to create a custom pagination view in Laravel that includes hidden form input elements to pass search terms and page numbers. Using a view composer, you can generate hidden form inputs based on user input and append them to the pagination view, allowing users to navigate through search results while maintaining their search criteria. Additionally, you can use the appends() method to include input and URL parameters when generating pagination links, ensuring that search data is preserved when users click on the links.

Laravel

Part One: Creating a Custom Pagination View in Laravel

John Koster
John Koster
July 21, 2014

Learn how to create a custom paginator view in Laravel 4 that allows users to enter a specific page number in a text box and jump to that page. The tutorial walks you through implementing the view step-by-step, including adding clickable links and the text box. The end result is a simple pagination view with a text box that lets users easily navigate through large data sets without an infinite-scroll-like solution. Note that the tutorial mentions the use of inline styles, which ideally should be separated into their own stylesheet, and also hints at a part 2 that covers handling filtered data sets.

Laravel

Getting Kint to Work With Laravel 4.1

John Koster
John Koster
May 14, 2014

Kint is a PHP tool designed to make debugging PHP easier and more organized. It takes output from PHP's var_dump() and debug_backtrace() functions and formats it nicely. While not part of Laravel itself, Kint can be used in conjunction with Laravel's dd function for a powerful debugging combination. Some users have had issues getting Kint to work with Laravel, but one solution is to modify the order of dependencies in the composer.json file. Alternatively, you can manually adjust the autoload_files.php file to ensure that Kint is loaded before Laravel.

Laravel

Laravel 4: Be Careful With Your After Filters

John Koster
John Koster
April 4, 2014

Learn how to use the after filter in Laravel 4 to perform tasks after your routes and controllers have run. This filter can be used for various purposes, such as logging or checking specific conditions. By using the after filter, you can manipulate the response content before it is sent to the client. However, if you are working with views and want to avoid potential issues with nested queries being executed twice, it is recommended to use the getContent() function instead of casting the view object to a string.

Laravel

Laravel 4: Working With Checkboxes and Input

John Koster
John Koster
April 1, 2014

Learn how to create a checkbox in a Blade view using the Form class in Laravel. You can check if a checkbox is checked in a controller by using an if statement. Ensure the checked state of the checkbox is set by passing a boolean value as the third argument in the checkbox function. You can also use Input::old() to set the checked state based on the previous input.

Laravel

Laravel: Calling Artisan Commands From Your Application

John Koster
John Koster
March 27, 2014

Learn how to run Artisan commands from within your application's code with this helpful tip. You can use the Artisan::call method to execute commands, and even pass command options as arguments. Keep in mind that when calling commands from your application, the paths are relative to the location of the calling file. You can simplify path management by using Laravel's path helper functions.

Laravel

Laravel 4: Default Events

John Koster
John Koster
March 25, 2014

Laravel 4 provides a variety of events that are fired throughout your application's life cycle, such as auth.attempt, auth.login, auth.logout, and more. These events are called in specific files like /Illuminate/Auth/Guard.php and /Illuminate/Database/Connection.php. You can find where an event is called or explore available events in this quick reference. Keep an eye on this page for updates and additional event information.

Laravel

Laravel 4: Getting User Input

John Koster
John Koster
November 2, 2013

Learn how to get input from users in Laravel 4 using the Input facade. Find out how to get the value of a specific input element by name, and how to specify a default value if the input is empty. Additionally, discover how to get all of the input values as an associative array using the all() method. Learn how to handle ambiguous input when there are variables with the same name in both a POST request and a URL query parameter. Finally, see how to specify the source of the data you want using the instance() method and access the POST and query data directly.

Laravel

Laravel 4: Rendering a View to a String

John Koster
John Koster
October 31, 2013

Laravel 4 provides a way to separate controllers and business logic from the presentation layer through its Views feature. Instead of outputting a view directly to the client, you can render it into a local variable. This is especially useful when you need to further process the view as a string, such as generating a PDF of the web page. Laravel 4's View::make()->render() method allows you to accomplish this.

Latest posts

That Escalated Quickly: All the New Things

The past six months or so have been incredibly busy. What started as a new article series about cust...

Read more
Troubleshooting a Statamic Illegal Offset Type Error when Viewing Collection Entries in the Control Panel

In this post I talk about how I resolved a mysterious illegal offset type error when viewing collect...

Read more
Creating Simple HTTP Redirect Routes from a Statamic Site

Generating a custom Laravel routes file from a Statamic website to redirect to a new domain.

Read more
Disabling Vite File Hashes

Disabling file hashes in Vite output can be accomplished by modifying your project's vite.config.js

Read more
Implementing a Custom Laravel Blade Precompiler for Volt and Livewire

Learn how to implement a custom component compiler for Laravel's Blade templating language in this p...

Read more
Creating a Hybrid Cache System for Statamic: Part Five

Part 5 of 6 covers implementing a cache namespace and labeling system, which we can use to target mu...

Read more