Laravel Types of Functions and Methods

Posted by

Laravel, a powerful PHP web application framework, offers developers a versatile set of functions and methods that serve distinct purposes in the development process. Laravel’s diverse range of functions and methods caters to different aspects of web development, from routing to database interactions and user authentication. By understanding and utilizing these functions effectively.

  1. Routing Functions: Navigating the Web Landscape
  1. get(): Defines a route for handling GET requests.
  2. post(): Defines a route for handling POST requests.
  3. put(), patch(), delete(): Handle respective HTTP request methods.

2. Controller Functions: Orchestrating Actions

  1. index(): Handles displaying a list of resources.
  2. show(): Displays a specific resource.
  3. create(), store(): Manages resource creation.
  4. edit(), update(): Handle resource editing and updating.
  5. destroy(): Deletes a resource.

3. Model Functions: Interacting with the Database

  1. find(): Retrieves a record by its primary key.
  2. all(): Fetches all records from a table.
  3. create(), update(), delete(): Perform CRUD operations.

4. Database Query Functions: Crafting Precise Queries

  1. select(): Specifies columns to retrieve.
  2. where(), orWhere(): Adds conditions to the query.
  3. join(): Combines rows from different tables.

5. Middleware Functions: Fine-Tuning Request Processing

  1. handle(): Executes code before the request reaches the controller.
  2. terminate(): Code executed after the response is sent.

6. Authentication Functions: Safeguarding User Access

  1. auth(): Provides access to the authenticated user.
  2. login(), logout(): Manage user authentication status.

7. Validation Functions: Ensuring Data Integrity

  1. validate(): Validates incoming request data against defined rules.
  2. sometimes(): Conditionally applies validation rules.

8. Session Functions: Managing User State

  1. session(): Retrieves or stores data in the session.
  2. flash(): Stores data in the session for the next request.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x