Laravel Application Helper: auth Nov 20, 2016
The auth helper function in Laravel is used to retrieve an instance of Illuminate\Contracts\Auth\Factory, which is responsible for handling authentication. It is an alternative to using the Auth facade. If no arguments are provided, auth() returns the currently logged in user. You can also specify a custom authentication guard by passing the guard name as an argument. When $guard is set to null, the AuthManager instance uses the default guard specified in the configuration file.
Laravel Application Helper: base_path Nov 20, 2016
The base_path function in Laravel retrieves the path to the directory where the application is installed. It can also be used to construct paths relative to the base path. In the given example, the base_path function is used to retrieve the base path and construct paths for the app and public directories. Note that the function does not automatically add a trailing slash to the path.
Laravel Application Helper: config_path Nov 20, 2016
The config_path function in Laravel retrieves the path to the config directory and can be used to construct paths relative to it. An optional $path parameter allows for specific file paths to be constructed. In this example, the resulting paths are displayed as comments above the function calls.
Laravel Application Helper: database_path Nov 20, 2016
The database_path function in Laravel retrieves the path to the database directory. By supplying a $path, you can construct paths relative to the database directory. For example, calling database_path() will return the path to the /home/vagrant/Code/Laravel/database directory, while database_path('migrations') will return the path to the /home/vagrant/Code/Laravel/migrations directory. Additionally, the str_finish function can be used to ensure a trailing slash is added to the path, as shown in the example str_finish(database_path('seeds'), '/').
Laravel Application Helper Function: abort Nov 20, 2016
The abort function is used to throw an HTTP exception with the given code, message, and headers. This exception can be caught and handled in the application's kernel. If the code is 404, the function will return a "Not Found" exception using the provided message. In the example, if the $user object does not have the admin property set to true, the code will abort with a 401 unauthorized access error.
Laravel Application Helper Function: back Nov 20, 2016
The back helper function in Laravel creates a redirect response to the user's previous location. It takes two optional parameters to control the status code and headers of the response. You can change the status code to be either "Found" or "Moved Permanently" and you can supply additional headers. There are different ways to return a redirect response using the Redirect facade, the response helper function, or the back helper function itself. You can also change the status code or supply additional headers as needed.
Laravel Application Helper Function: dispatch Nov 20, 2016
The dispatch helper function allows you to easily push a new job onto the job queue. It resolves the Dispatcher instance from the Service Container and calls the dispatch method. You can also use app(Dispatcher::class)->dispatch($job) or Bus::dispatch($job) as alternatives to the helper function.
Laravel Application Helper Function: event Nov 20, 2016
The event helper is a useful function for dispatching events and notifying their listeners. It allows you to pass a payload of data when dispatching the event, and the responses from the listeners are stored in an array. By setting the $halt parameter to true, the dispatcher will stop calling listeners after a non-null response is received. You can fire an event by specifying the class name or by instantiating a new instance of the event class itself. If no payload is supplied, the event instance itself will be used as the payload.
Laravel Application Helper Function: factory Nov 20, 2016
The factory() function is used to create Eloquent models, primarily for testing applications. This method allows you to generate one or more instances of a specific model, with the option to apply modifications previously defined using the bind method. Example uses include returning a single instance of a user model, returning multiple instances, or applying modifications bound to a specific description like 'admin'.
Laravel Application Helper Function: method_field Nov 20, 2016
The method_field helper function in Laravel returns an instance of Illuminate\Support\HtmlString containing a hidden HTML input field. This field has the name _method and a value passed as an argument to the function. See examples with different methods: PUT, POST, GET, PATCH, DELETE. The return value is an HtmlString instance, corresponding to an HTML hidden input field.
Laravel Application Helper Function: redirect Nov 20, 2016
The redirect helper function in Laravel is used to redirect users to different URLs. When the $to parameter is set to null, the function returns an instance of the Illuminate\Routing\Redirector class. You can use the redirect function to access various methods of the Redirector, such as back(), home(), and to('/'), to control user flow in your application. If you provide a URL as the $to parameter, the redirect function internally calls the to method on the Redirector instance. You can also generate secure (HTTPS) URLs by setting the $secure parameter to true. Additionally, you can change the HTTP status code and supply additional headers by providing arguments for the $status and $headers parameters, respectively.
Laravel Application Helper Function: request Nov 20, 2016
The request helper function in Laravel is used to retrieve data from the user's input. To retrieve an instance of Illuminate\Http\Request, call the request method without any arguments. To retrieve an input value, provide at least the $key argument. You can also use the request function as a shortcut to the Request::input method. It can be used to retrieve a subset of the user's input data or to retrieve input with a default value if no input is found.
Laravel Application Helper Function: validator Nov 20, 2016
Learn how to use the validator helper function in Laravel to validate input data. The validator function is a versatile helper function that can be used with or without arguments. When used without arguments, it returns an instance of Illuminate\Contracts\Validation\Factory that provides access to validation methods. You can also use the validator function with arguments to directly call the make method on the factory instance.
Laravel Application Helper Function: view Nov 20, 2016
The view function in Laravel can be used to return a view instance or a view factory. When called without arguments, it returns the view factory. When called with arguments, it creates a view instance based on the provided view file name, initial data, and additional data to be merged. The provided data can be an array or an object that implements the Arrayable interface. To render a view to a string, you can use the render method on the view instance.