Laravel glossary

Laravel glossary

Concept of Laravel

Laravel

Understanding the Laravel glossary is critical to effectively working with the framework. The glossary is a list of terms and their definitions that are specific to Laravel. It's important to understand these terms because they are used throughout the Laravel documentation and by the Laravel community.

request class

The make:request command in Laravel is used to generate a new form request class. Form request classes in Laravel provide a convenient way to validate incoming HTTP request with a variety of powerful validation rules.

php artisan make:request MyFormRequest

In this example, MyFormRequest is the name of the request class you want to create. After running this command, a new file will be created at

app/Http/Requests/MyFormRequest.php.

Inside the generated class, you will find two methods: authorize and rules.

Authorize method:

Determines if the user is authorized to make this request. For instance, you might check if the authenticated user is the owner of a blog post before they can update it. By default, this method returns false, so you should modify this as needed for your application.

Rules method

Here you define validation rules that apply to the request. For example, if you have a request that updates a user's information, you might ensure that the user's email address is unique.

"=>" & "->" Symbol

The => symbol in PHP is known as the "double arrow" or "array assignment operator". It's used to associate a key with a value in an associative array.

The -> symbol in PHP is known as the "object operator", used to access properties and methods of an object.

make:resource

The php artisan make:resource command in Laravel is used to create a new resource. A resource in Laravel is a way to transform your Eloquent model data when sending it to the client. This is especially useful in APIs, where you may want to limit the data sent or transform it in some way.