The Blog

Laravel 5

Laravel 5: Accessing and Manipulating Configuration Values With config

John Koster
John Koster
April 14, 2018

The config function in Laravel can be used to resolve an instance of the configuration repository from the Service Container, or to get or set configuration values at runtime. It has multiple signatures allowing for different usage scenarios. When used without any arguments, it returns an instance of the configuration repository. The function can also be used to set configuration values by providing an array of key/value pairs, and it can retrieve configuration values by providing a key, with an optional default value if the key does not exist.

Laravel 5

Laravel 5: Accessing and Manipulating Session Data With session

John Koster
John Koster
April 14, 2018

The session function in Laravel allows you to resolve the session manager instance from the service container, retrieve session values, and set new session values. You can return an instance of the session manager class by setting the $key parameter to null. To set session values, you can pass an array of key/value pairs to the session function. Retrieving session values is done by supplying a $key to the function call, and you can provide a default value in case the session value does not exist.

Laravel 5

Laravel 5: Accessing and Sending HTTP Responses With response

John Koster
John Koster
April 14, 2018

The response helper function in Laravel is a versatile function that can be used to accomplish different tasks. When called without any arguments, it returns an instance of "Illuminate\\Contracts\\Routing\\ResponseFactory" by default. It can also be used as a shortcut to the ResponseFactory::make method by passing content, status, and headers as arguments. Additionally, you can change the HTTP status code and supply additional headers when using the response function.

Laravel 5

Laravel 5: Accessing HTTP Request Details With request

John Koster
John Koster
April 14, 2018

The request helper function allows you to retrieve either an instance of Illuminate\Http\Request or an item from the user's input. To retrieve an instance of Request, call the request method without arguments. To retrieve an input value, provide at least the $key argument. The helper function can also be used as a shortcut for the Request::input method, with examples given. Additionally, the request function allows you to access a subset of the user's input data by using the only method or by providing an array as the only argument.

Laravel 5

Laravel 5: Accessing Session Input Data With old

John Koster
John Koster
April 14, 2018

The old helper function in Laravel is used to retrieve an old input item. It accepts a key argument and an optional default value. You can use it to easily retrieve old input data by specifying the key of the input item you want to retrieve. If no key is specified or the specified key does not exist, the function will return the provided default value or null. There are multiple ways to use the old helper function, including using the Input facade or the request() helper function.

Laravel 5

Laravel 5: Accessing the Authentication Manager With auth

John Koster
John Koster
April 14, 2018

The auth helper function in Laravel allows you to quickly access the authentication features of the framework. It can be used instead of the Auth facade to retrieve the currently logged in user. By default, the auth function returns an instance of Illuminate\Contracts\Auth\Factory, which is an instance of Illuminate\Auth\AuthManager. Custom authentication guards can also be accessed by providing an argument for the $guard parameter. When no argument is supplied, the AuthManager instance will use the default web guard.

Laravel 5

Laravel 5: Accessing the Cache System With cache

John Koster
John Koster
April 14, 2018

The cache helper function in Laravel allows you to access the cache store, retrieve existing items, and store new items in the cache. By using different argument combinations, you can control its behavior. You can easily check if an item exists in the cache using cache()->has('key'). You can also retrieve an item from the cache, and if it doesn't exist, you can specify a default value to be returned instead. Additionally, you can set new cache values with an expiration time.

Laravel 5

Laravel 5: Accessing the Logging Features With logger

John Koster
John Koster
April 14, 2018

The logger helper function in Laravel can be used to retrieve the logger instance from the Service Container or to log debug messages within your application. It eliminates the need to inject dependencies or use the Illuminate\Support\Facades\Log facade. The function signature includes parameters for the message and context, where the message can be written to log files and the context can be an array of any element type. Multiple examples of using the logger function are provided, along with the resulting log messages in the log files. Additionally, alternative methods for logging debug messages are shown, all of which are equivalent.

Laravel 5

Laravel 5: Accessing the Service Container With app

John Koster
John Koster
April 14, 2018

The app function in Laravel gives you access to the singleton Illuminate\Container\Container instance. It can be used to resolve registered dependencies from the Service Container. For example, to get an instance of Illuminate\Auth\AuthManager, you can use app('auth') or app()->make('auth').

Laravel 5

Laravel 5: Accessing Validation Features With validator

John Koster
John Koster
April 14, 2018

The validator helper function is a versatile function that allows you to validate data. It can be used without any arguments to return an instance of the validation factory. You can also use it with arguments, similar to the Validator facade, to perform validation on input data. Overall, the validator helper function is a convenient way to perform data validation in Laravel.

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