abort
The abort function throws back a specified HTTP exception.
copy
The abort function throws back a specified HTTP exception.
copy
The abort if function throws back a specified HTTP exception if the first attribute evaluates to true.
copy
The abort unless function throws back a specified HTTP exception if the first attribute evaluates to false.
copy
Auth helper functions.
copy
There are a few ways to apply the auth middleware in your project.
copy
Returning back function will redirect the user to the previous step.
copy
Belongs to sets a single-to-single relationship between two Models. Use it for fetching a parent Model associated with your class. Pass a Model class you want to reference as an argument.
copy
In some cases you might need to clear Laravel's cache without using console. You can set up the following route and run Artisan cache clear command as a call-back function instead. In addition, follow it up with Artisan config cache command to rebuild application cache again. Then, visit the new route in your browser to trigger the Artisan commands.
copy
Compact function allows you to pass data to the view.
copy
Returns the configuration record value using the dot notation. Second argument lets you pass an optional default value.
copy
Create method lets you set and persist a new item in one simple command.
copy
Cross-Site Request Forgery token.
copy
Set a default value of the record in the Migration class.
copy
Helpful debugging function.
copy
Add the following code to AppService provider within the boot() method. It will help with catching common errors in your production environment.
copy
A helper function for raising events.
copy
Run Factory class in tinker to quickly generate database records. You can create multiple records in one go by passing a number of records to create as the second factory argument.
copy
Faker function lets you generate dummy data for seeding the database.
copy
Find or fail method provides support for requests that fail to return any data from the data base. Rather than letting the app crash it captures the error and displays an in-built, user-friendly message.
copy
Set a foreign key in the data base table. Makes a reference between tables using an id and a foreign key.
copy
Has many sets a single-to-many relationship between two Models. Use plural form in the name of your function (subitems in this example). This is a good practice as a collection of records will be returned when the method is called. Pass a Model class you want to reference as an argument.
copy
Example of joining to collections using join function helper. First argument determines a table to join, the two following arguments select columns to make the join at.
copy
Navigate to the directory you want to start the new Laravel project and run the following command.
copy
Submit a log message to configured channels. There is eight types of messages to choose from, alert, emergency, error, critical, debug, info, notice and warning. Debug type has been used in the code example.
copy
Method field in Laravel provides the missing support for the requests like PATCH and DELETE.
copy
Examples of passing data to a view.
copy
Pluck is an eloquent helper function for narrowing down your database queries and returning a collection of specific columns.
copy
Add the following code to AppService provider within the boot() method. This is to flag an issue when Laravel is trying to make unnecessary calls to the database. The passed attribute evaluates to a boolean and ensures the debug message doesn't display in the production environment.
copy
This command will install only the production dependencies from your composer.json file. This is typically used when deploying application to production environments.
copy
Protected method allows to set fillable or guarded fields in the model.
copy
Revert items order in the collection.
copy
Basic route example returning a view. Routes are located in the /routes folder of your application.
copy
Use route helper to return a full url to a named route. You can pass parameters in the second argument for the dynamic parts of the url.
copy
Using resource method will create a complete list of routes required for listing, creating, storing, editing and removing items.
copy
Unique function protects database from holding multiple records with the same value.
copy
Validate function allows you to set rules for the data passed in the request. If the validation fails Laravel returns an Errors object.
copy