The Blog

Laravel

Laravel Miscellaneous Helper Function: windows_os

John Koster
John Koster
November 21, 2016

The windows_os helper function checks if the server is running a Microsoft Windows® operating system. By using this function, you can simplify the code and write Windows®-specific commands or instructions separately from non-Windows® code. Eliminate the need for a complex check using substr() and strtolower().

Laravel

Laravel Miscellaneous Helper Function: with

John Koster
John Koster
November 21, 2016

The with function in PHP simply returns the supplied object. It allows you to invoke methods on new class instances that are passed as function arguments. An alternative to using the with function is to wrap object instantiation within a pair of parentheses. Both techniques achieve the same result, but the with function may enhance readability and clarify intent.

Laravel

Laravel Router Helper Function: delete

John Koster
John Koster
November 21, 2016

The delete function is used to register a route with the router that will respond to the DELETE HTTP verb. You provide the $uri and the $action that will be executed when the route is matched. The $action can be a closure or a mapping to a controller method. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: get

John Koster
John Koster
November 21, 2016

The get function in Laravel is used to register a route that responds to the GET HTTP verb. It takes a URI and an action as parameters, where the URI is the path of the route and the action is what will be executed when the route is matched. The action can be a Closure or a mapping to a controller method. The return value of the get function is an instance of the \Illuminate\Routing\Route class. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: patch

John Koster
John Koster
November 21, 2016

The patch function in Laravel is used to register a route that responds to the PATCH HTTP verb. You can specify the URI of the route and the action that will be executed when the route is matched. The action can either be a Closure or a mapping to a controller method. You can use the patch function directly or use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: post

John Koster
John Koster
November 21, 2016

The post function in Laravel is used to register a route that responds to the POST HTTP verb. You can specify the URI of the route and the action that will be executed when the route is matched. The action can be a closure or a reference to a controller method. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: put

John Koster
John Koster
November 21, 2016

The put function is used to register a route that responds to the PUT HTTP verb. You provide the URI of the route and the action that will be executed when the route is matched. The action can be a closure or a mapping to a controller method. The function returns an instance of \Illuminate\Routing\Route. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: resource

John Koster
John Koster
November 21, 2016

Learn how to register a resource controller with the router using the resource function in PHP. Customize the $name, $controller, and $options of the route during construction. Find out how multiple individual routes are created behind the scenes.

Laravel

Laravel URL Helper Function: action

John Koster
John Koster
November 21, 2016

The action helper function in Laravel can generate a URL to a controller action. You can specify the controller action using the $name parameter and pass any required parameters using the $parameters parameter. By default, the generated URL will be an absolute URL, but you can specify a relative URL by setting the $absolute parameter to false.

Laravel

Laravel URL Helper Function: asset

John Koster
John Koster
November 21, 2016

The asset($path, $secure = null) function in Laravel returns a URI composed of the application's URI and the provided $path. You can specify if the URI should have the https:// or http:// schema by setting the optional $secure parameter. The function is useful for generating asset paths based on the application URI. Examples of different asset paths that can be generated are shown in the code snippet.

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