Laravel is an open-source widely used PHP framework. The platform was intended for the development of web application by using MVC architectural pattern. Laravel is released under the MIT license.
It is a back-end PHP-based and open-source framework used for building a wide range of custom web applications. It's an entirely server-side framework that manages data with the help of Model-View-Controller (MVC) design which breaks an application back-end architecture into logical parts.
Q2. What is the latest Laravel version?
The latest Laravel version is version 9, which was released on February 8, 2022.
Q3. Define composer?
Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. Composer runs through the command line and installs dependencies
composer create-project laravel/laravel 9.0
Q4. What do you mean by bundles?
In Laravel, bundles are referred to as packages. These packages are used to increase the functionality of Laravel.
A package can have views, configuration, migrations, routes, and tasks.
Q5. Explain traits in Laravel?
Laravel traits are a group of functions that you include within another class.
A trait is like an abstract class. You cannot instantiate directly, but its methods can be used in concreate class.
Q6. How will you register service providers?
You can register service providers in the config/app.php configuration file that contains an array where you can mention the service provider class name.
Q7. How can you enable query log in Laravel?
You can use enableQueryLog method to enable query log in Laravel.
Q8. Explain validation concept in Laravel?
Base controller trait uses a ValidatesRequests class which provides a useful method to validate requests coming from the client machine.
Q9. How can you reduce memory usage in Laravel?
While processing a large amount of data, you can use the cursor method in order to reduce memory usage.
Q10. Explain faker in Laravel?
It is a type of module or packages which are used to create fake data. This data can be used for testing purpose.
It is can also be used to generate: 1) Numbers, 2) Addresses, 3) DateTime, 4) Payments, and 5) Lorem text.
Q11. Define Laravel guard?
Laravel guard is a special component that is used to find authenticated users.
The incoming requested is initially routed through this guard to validate credentials entered by users. Guards are defined in ../config/auth.php file.
Q12. What is Laravel API rate limit?
It is a feature of Laravel. It provides handle throttling.
Rate limiting helps Laravel developers to develop a secure application and prevent DOS attacks.
Q13. What is Throttling in Laravel?
Throttling is a technique in which, no matter how many times the user fires the event, the attached function will be executed only once in a given time interval.
Ex:
Now, when throttling is applied with 5000 milliseconds (5 sec.) to the function(), no matter how many times the user clicks on the button, it will hit only once in 5000 milliseconds.
Throttling ensures that the function executes at a regular interval.
Q14. State the difference between authentication and authorization?
Authentication means confirming user identities through credentials, while authorization refers to gathering access to the system.
In another word we can say that, Authentication check the user's identity and Authorization check users are authorized for this system or not.
Q15. Explain to listeners?
Listeners are used to handling events and exceptions. The most common listener in Laravel for login event is LoginListener.
A Listener is a class that listens to the events that they are mapped to and execute a task, that is they are the ones that perform a given task for an event.
Q16. What do you mean by Laravel Dusk?
Laravel Dusk is a tool which is used for testing JavaScript enabled applications.
It provides powerful, browser automation, and testing API.
Dusk is a Laravel package that performs end-to-end (E2E) tests on Laravel applications. Providing client-side testing by running tests in a browser, Dusk allows developers to see client-side features tested in real time.
Normally, developers can use Selenium for JavaScript testing, but setting it up and learning to use it can be quite challenging. So, Laravel developers decided to provide an easier alternative that is Dusk.
Dusk also provides browser automation for applications while eliminating the complex steps required by ChromeDriver and PHP WebDriver individually.
composer require --dev laravel/dusk
Q17. Explain Laravel echo?
It is a JavaScript library that makes possible to subscribe and listen to channels Laravel events. You can use NPM package manager to install echo.
Q18. What is query scope?
It is a feature of Laravel where we can reuse similar queries. We do not require to write the same types of queries again in the Laravel project.
Once the scope is defined, just call the scope method when querying the model.
Q19. What is the use of the bootstrap directory?
It is used to initialize a Laravel project. This bootstrap directory contains app.php file that is responsible for bootstrapping the framework.
Q20. What is an Observer?
Model Observers is a feature of Laravel. Laravel Observers are used to group event listeners for a model eloquent.
Laravel Observers will listener event for model eloquent method like create, update and delete
Q21. What is named route?
Named routes is an important feature in the Laravel framework. In short, we can say that the naming route is the way of providing a nickname to the route.
Then you can use the name of the route while generating URLs or redirecting through a global route function.
As the name suggests, middleware works as a middleman between request and response. Middleware is a form of HTTP requests filtering mechanism.
For example, Laravel consists of middleware which verifies whether the user of the application is authenticated or not.
If a user is authenticated and trying to access the dashboard then, the middleware will redirect that user to home page; otherwise, a user will be redirected to the login page.
HTTP middleware is a technique for filtering HTTP requests. Laravel includes a middleware that checks whether application user is authenticated or not.
Q23. Types of Middleware?
There are three types of Middleware in Laravel.
Global Middleware
Route Middleware
Groups Middleware
Global Middleware: The Global Middleware will run on every HTTP request of the application.
Route Middleware: The Route Middleware will be assigned to a specific route.
Groups Middleware: Sometimes you may want to group several middleware under a single key to make them easier to assign to routes. You may accomplish this using the $middlewareGroups.
Q24. What is Chunk?
Basically, Laravel eloquent chunk method break the large group of data set into smaller group of data set (chunks)
If you are working with 10000 of records, then chunk is usefull. It split query into small queries and reduce your memory uses.
Event
Events are the ways we hook into the activities of our application, it is just a way to observe an activity, for instance, login, a class can be created to monitor the activity of login, when a user logs in, the event class can execute some functions.
Listeners
A Listener is a class that listens to the events that they are mapped to and execute a task, that is they are the ones that perform a given task for an event.
Q27. How to remove CSRF?
app > http > kernal > at web section, comment VerifyCSRFToken
app > http > middelwear > VerifyCSRFToken.php and here $except take array argument so we can pass route url here.
Q28. What do you know about Laravel Contracts?
Laravel's Contracts are the set of interfaces which are responsible for defining the core functionality of services provided by the Laravel framework.
Each contract has a corresponding implementation provided by the framework. For example, Laravel provides a queue implementation with a variety of drivers, and a mailer implementation that is powered by Symfony Mailer.
Q29. How will you explain homestead in Laravel?
Homestead is an official, pre-packaged, vagrant virtual machine which provides Laravel developers all the necessary tools to develop Laravel out of the box.
It also includes Ubuntu, Gulp, Bower, and other development tools which are useful in developing full-scale web applications.
It provides a development environment which can be used without the additional need to install PHP, a web server, or any other server software on the machine.
Q30. Name aggregates methods of query builder?
Aggregates methods of query builder are:
max()
min()
sum()
avg()
count().
Q31. What is a Route?
A route is basically an endpoint specified by a URI (Uniform Resource Identifier). It acts as a pointer in Laravel application.
Most commonly, a route simply points to a method on a controller and also dictates which HTTP methods are able to hit that URI.
Routes are stored inside files under the /routes folder inside the project’s root directory.
Q32. Explain important directories used in a common Laravel application?
Directories used in a common Laravel application are:
App/: This is a source folder where our application code lives. All controllers, policies, and models are inside this folder. Config/: Holds the app’s configuration files. These are usually not modified directly but instead, rely on the values set up in the .env (environment) file at the root of the app. Database/: Houses the database files, including migrations, seeds, and test factories. Public/: Publicly accessible folder holding compiled assets and of course an index.php file.
Q33. Explain reverse routing in Laravel?
Laravel reverse routing is generating URL's based on route declarations. Reverse routing makes your application so much more flexible.
It defines a relationship between links and Laravel routes. When a link is created by using names of existing routes, appropriate Uri's are created automatically by Laravel.
Here is an example of reverse routing.
Using reverse routing we can create a link to it and pass in any parameters that we have defined. Optional parameters, if not supplied, are removed from the generated link.
Facades provide a static interface to classes that are available in the application's service container.
It's providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.
In a Laravel application, a facade is a class that provides access to an object from the container.
All facades of Laravel have defined in Illuminate\Support\Facades namespace.
Facade provides all laravel features such as, DB, Session, Cookies, Views, Cache and many more.
So with the help of this facade we can perform task easily. Facade registered in Service Container. It allows us to use Non Static function as Static function using Scope Resolution.
Q35. What does ORM stand for?
ORM stands for Object Relational Mapping.
Eloquent ORM refer to an advanced implementation of the PHP Active Record Pattern, which makes it very easy to interact with application database.
Eloquent ORM makes it incredibly easy to perform CRUD (Create, Read, Update, Delete) operations on Laravel Model.
ORM is a technique that helps developers to address, access, and manipulate objects.
With the help of ORM we can direct communicate with Database without using pure sql query, here we need some predefined function to communicate with database.
Q36. What is the difference between laravel cursor and laravel chunk method?
This is chunk:
If you need to process thousands of Eloquent records, use the chunk command. chunk query in to queries with limit and offset. Pros controllableused memory size Cons
turned results in to eloquent models batchly may cause some memory overhead
This is Cursor:
The cursor method allows you to iterate through your database records using a cursor, which will only execute a single query. Pros minimize eloquent model memory overhead easy to manipulate Cons huge result leads to out of memory
100,000 records:
methods
Time(sec)
Memory(MB)
get()
0.8
132
chunk(100)
19.9
10
chunk(1000)
2.3
12
chunk(10000)
1.1
34
cursor()
0.5
45
Q37. Types of relationships in Laravel Eloquent?
Types of relationship in Laravel Eloquent are:
One To One
One To Many
Many To Many
Has Many Through
Polymorphic Relations.
Q38. Why are migrations important?
Laravel Migration is an essential feature in Laravel that allows you to create a table in your database.
It allows you to modify and share the application's database schema. You can modify the table by adding a new column or deleting an existing column.
Migrations are important because it allows you to share application by maintaining database consistency.
Without migration, it is difficult to share any Laravel application. It also allows you to sync database.
Q39. Why do we need Laravel Migration?
Suppose we are working in a team, and some idea strikes that require the alteration in a table. In such a case, the SQL file needs to be passed around, and some team member has to import that file, but team member forgot to import the SQL file. In this case, the application will not work properly, to avoid such situation, Laravel Migration comes into existence.
In simple words you can say that, It is just like Verson Control for Database.
Q40. What is lumen in laravel?
Lumen is an open-source PHP micro-framework created by Taylor Otwell as an alternative to Laravel to meet the demand of lightweight installations that are faster than existing PHP micro-frameworks such as Slim and Silex.
With Lumen, you can build lightning-fast microservices and APIs that can support your Laravel applications.
Q41. List out common artisan commands used in Laravel?
Laravel supports following artisan commands:
PHP artisan down,
PHP artisan up,
PHP artisan make:controller,
PHP artisan make:model,
PHP artisan make:migration,
PHP artisan make:middleware,
Q42. Differentiate between delete() and softDeletes() in Laravel?
delete():remove all record from the database table.
softDeletes(): It does not remove the data from the table. It is used to flag any record as deleted.
Q43. List basic concepts in Laravel?
Following are basic concepts used in Laravel:
Routing
Eloquent ORM
Middleware
Security
Caching
Blade Templating
Q44. Define @include in Laravel?
@include is just like a basic PHP include, it includes a "partial" view into your view.
@extends lets you "extend" a template, which defines its own sections etc. A template that you can extend will define its own sections using @yield , which you can then put your own stuff into in your view file.
@include is used to load more than one template view files.
It helps you to include view within another view.
User can also load multiple files in one view.
Q45. Which file is used to create a connection with the database?
To create a connection with the database, you can use .env file.
Q46. What is a session in Laravel?
Session is used to pass user information from one web page to another.
Laravel provides various drivers like a cookie, array, file, Memcached, and Redis to handle session data.
To access the session data, we need an instance of session which can be accessed via HTTP request. After getting the instance, we can use the get() method, which will take one argument, 'key', to get the session data.
// Get Session Data
$value = $request->session()->get('key');
// Crete Session Data
$request->session()->put('key', 'value');
// Delete Session Data
$request->session()->forget('key');
Q47. How to access session data?
Session data be access by creating an instance of the session in HTTP request. Once you get the instance, use get() method with a 'Key' as a parameter to get the session details.
// Get Session Data
$value = $request->session()->get('key');
Q48. What is the default session timeout duration in Laravel?
The default Laravel session timeout duration is 2 hours.
Q49. What are policies classes?
Policies classes include authorization logic of Laravel application. These classes are used for a particular model or resource.
For example, let's say you have a Post model in your application, and you want to authorize the CRUD actions of that model. In that case, it's the policy that you need to implement.
class PostPolicy
{
public function view(User $user, Post $post) {}
public function create(User $user) {}
public function update(User $user, Post $post) {}
public function delete(User $user, Post $post) {}
}
Q50. What is make method?
Laravel developers can use make method to bind an interface to concreate class. This method returns an instance of the class or interface.
Laravel automatically inject dependencies defined in class constructor.
$app->make('App\Services\MyService'); // new \App\Services\MyService.
Q51. Explain Response in Laravel?
All controllers and routes should return a response to be sent back to the web browser. Laravel provides various ways to return this response.
The most basic response is returning a string from controller or route.
Q52. What is namespace in Laravel?
A namespace allows a user to group the functions, classes, and constants under a specific name.
In PHP you can’t have two classes that share the same name. They have to be unique.
Namespaces can be defined as a class of elements in which each element has a unique name to that associated class.
Q53. What is Laravel Forge?
Laravel Forge is a server management and site deployment service.
Laravel Forge helps in organizing and designing a web application.
Although the manufacturers of the Laravel framework developed this toll, it can automate the deployment of every web application that works on a PHP server.
In addition, Forge can assist you in managing scheduled jobs, queue workers, SSL certificates, and more.
Q54. How to remove a compiled class file?
Use clear-compiled command to remove the compiled class file.
Q55. In which folder robot.txt is placed?
You can control which files crawlers may access on your site with a robots.txt file.
A robots.txt file lives at the root of your site. So, for site www.example.com, the robots.txt file lives at www.example.com/robots.txt.
robots.txt is a plain text file that follows the Robots Exclusion Standard. A robots.txt file consists of one or more rules.
Each rule blocks or allows access for a given crawler to a specified file path in that website. Unless you specify otherwise in your robots.txt file, all files are implicitly allowed for crawling.
Robot.txt file is placed in Public directory.
Q56. Explain API.PHP route?
Its routes correspond to an API cluster. It has API middleware which is enabled by default in Laravel.
These routes do not have any state and cross-request memory or have no sessions.
Q57. What is Localization?
It is a feature of Laravel that supports various language to be used in the application.
A developer can store strings of different languages in a file, and these files are stored at resources/views folder.
Developers should create a separate folder for each supported language.
Q58. Define hashing in Laravel?
Hashing is the process of transforming a string of characters into a shorter fixed value or a key that represents the original string.
Laravel uses the Hash facade which provides a secure way for storing passwords in a hashed manner.
use Illuminate\Support\Facades\Hash;
$password = request('password'); // get the value of password field
$hashed = Hash::make($password); // encrypt the password
$pass = Hash::check($password, $data->password); // For check password
Q59. Explain the concept of encryption and decryption in Laravel?
It is a process of transforming any message using some algorithms in such way that the third user cannot read information.
Encryption is quite helpful to protect your sensitive information from an intruder.
Encryption is performed using a Cryptography process. The message which is to be encrypted called as a plain message.
The message obtained after the encryption is referred to as cipher message. When you convert cipher text to plain text or message, this process is called as decryption.
Q60. Explain web.php route?
Web.php is the public-facing 'browser' based route. This route is the most common and is what gets hit by the web browser.
They run through the web middleware group and also contain facilities for CSRF protection (which helps defend against form-based malicious attacks and hacks) and generally contain a degree of “state”.
Q61. Does Laravel support caching?
Yes, Laravel provides support for popular caching backends like Memcached and Redis.
By default, Laravel is configured to use file cache driver, which is used to store the serialized or cached objects in the file system.
For huge projects, it is suggested to use Memcached or Redis.
Q62. What is Query Builder in Laravel?
Laravel's Query Builder provides more direct access to the database, alternative to the Eloquent ORM.
It doesn't require SQL queries to be written directly. Instead, it offers a set of classes and methods which are capable of building queries programmatically.
It also allows specific caching of the results of the executed queries.
Q63. How to clear cache in Laravel?
The syntax to clear cache in Laravel is given below:
Q65. What do you know about Service providers in Laravel?
Service providers can be defined as the central place to configure all the entire Laravel applications. Applications, as well as Laravel's core services, are bootstrapped via service providers.
These are powerful tools for maintaining class dependencies and performing dependency injection.
Service providers also instruct Laravel to bind various components into the Laravel's Service Container.
Almost, all the service providers extend the Illuminate\Support\ServiceProviderclass.
An artisan command is given here which can be used to generate a service provider:
php artisan make: provider ClientsServiceProvider
Q66. What do you know about Service Container in Laravel?
When a class depends on another class, or we can say when we use a class object into another class than it is called Dependancy Injection.
So for remove this dependancy we use some technique, like Interface or Constructor or Setter or something eles are called service container in Laravel.
Service container are used to manage class dependancy and perform dependancy injection.
Service Container bindings, event listeners, middlewares, and even routes using its service providers.
Q67. List some official packages provided by Laravel?
Passport: It provides a full Oauth2 server implementation for Laravel application in a matter of minutes.
Cashier: Laravel cashier implements an expressive, fluent interface to Stripe's and Braintree's subscription billing services.
Q68. What do you know about CSRF token in Laravel?
CSRF protection stands for Cross-Site Request Forgery protection.
CSRF detects unauthorized attacks on web applications by the unauthorized users of a system.
The built-in CSRF plug-in is used to create CSRF tokens so that it can verify all the operations and requests sent by an active authenticated user.
/* =============== Method 1 ===============*/
<form method="POST">
@csrf // Auto generate hidden input field
.....
</form>
XSS stands for cross-site scripting. It’s one of the top security risks that affect web applications.
In an XSS attack, attackers look for vulnerabilities on a website that will let them inject malicious scripts into the website. Once attackers get their scripts injected, they can control the behavior of the victim’s site and steal user data.
A simple XSS attack can occur on a vulnerable website that accepts user input via a GET parameter and displays the data on the webpage.
You can use Input::all(), strip_tags(), and array_map() to protect from XSS attack.
$input = array_map('strip_tags', \Input::all());
Q70. What are the validations in Laravel?
Validations are approaches that Laravel use to validate the incoming data within the application.
They are the handy way to ensure that data is in a clean and expected format before it gets entered into the database.
Laravel consists of several different ways to validate the incoming data of the application.
By default, the base controller class of Laravel uses a ValidatesRequests trait to validate all the incoming HTTP requests with the help of powerful validation rules.
Q71. What do you understand by Unit testing?
Unit testing is built-in testing provided as an integral part of Laravel. It consists of unit tests which detect and prevent regressions in the framework.
Unit tests can be run through the available artisan command-line utility.
Q72. How will you create a helper file in Laravel?
We can create a helper file using composer as per the given below steps:
Make a file "app/helpers.php" within the app folder.
Add
"files": [
"app/helpers.php"
]
in the "autoload" variable.
Now update composer.json with composer dump-autoload or composer update.
Q73. State the difference between get and post method?
GET
POST
GET method is used for requesting data from a specified resource.
POST is used for sending the data to the server as a package in a separate communication with the processing script.
GET method cannot be used for sending binary data like images or word documents
The POST method can be used to send ASCII as well as binary data like images and word documents
Data is sent in the form of URL parameters which are strings of name-value pairs separated by ampersands(&)
Data sent through the POST method will not be seen in the URL
This method must not be used if you have any sensitive information like a password to be sent to the server.
Sensitive information can be sent using this method.
You can use this method only for data that is not secure.
Data sent through this method is secure.
It can be used for submitting the form where the user can bookmark the result.
Submissions by form with POST cannot be bookmarked.
GET method is not safer since parameters may be stored in web server logs or browser history.
POST method is safer than GET because the parameters are not stored in web server logs or browser history.
Q74. How can you generate URLs?
Laravel has helpers to generate URLs. This is helpful when you build link in your templates and API response.
Q75. Which class is used to handle exceptions?
Laravel exceptions are handled by App\Exceptions\Handler class.
Q76. What are common HTTP error codes?
Error- 401 – Displays when an error is not authorized
Error 404 – Displays when Page is not found.
Q77. How to define environment variables in Laravel?
The environment variables can be defined in the .env file in the project directory.
New laravel application comes with a .env.example and while installing we copy this file and rename it to .env and all the environment variables will be defined here.
Q78. How to put Laravel applications in maintenance mode?
Maintenance mode is used to put a maintenance page to customers and under the hood, we can do software updates, bug fixes, etc. php artisan down
And can put the application again on live using: php artisan up
Q79. What are seeders in Laravel?
Seeders in Laravel are used to put data in the database tables automatically.
After running migrations to create the tables, we can run "php artisan db:seed" to run the seeder to populate the database tables.
Q80. Explain fluent query builder in Laravel?
It is a database query builder that provides convenient, faster interface to create and run database queries.
Q81. What are factories in Laravel?
Factories are a way to put values in fields of a particular model automatically. Like, for testing when we add multiple fake records in the database, we can use factories to generate a class for each model and put data in fields accordingly.
Every new laravel application comes with database/factories/UserFactory.php
php artisan make:factory UserFactory --class=User
Q82. What is the use of dd() function?
This function is used to dump contents of a variable to the browser. The full form of dd is Dump and Die.
dd($variable)
Q83. How to make real time sitemap.xml file in Laravel?
You can create all web pages of a website to tell the search engine about the organizing site content. The crawlers of search engine read this file intelligently to crawl a website.
Q84. What is the difference between insert() and insertGetId() in Laravel?
Insert(): This function is simply used to insert a record into the database. It not necessary that ID should be autoincremented.
InsertGetId(): This function also inserts a record into the table, but it is used when the ID field is auto-increment.
Q85. Explain active record concept in Laravel?
In active record, class map to your database table. It helps you to deal with CRUD operation
Q86. Define Implicit Controller?
Implicit Controllers help you to define a proper route to handle controller action. You can define them in route.php file with Route:: controller() method.
Q87. Explain logging in Laravel?
Laravel Logging is a way to log information that is happening inside an application. Laravel provides different channels for logging like file and slack. Log messages can be written on to multiple channels at once as well.
For example, the single channel writes log files to a single log file, while the slack channel sends log messages to Slack.
We can configure the channel to be used for logging in to our environment file or in the config file at config/logging.php.
Q88. How to use the custom table in Laravel Model?
In order to use a custom table, you can override the property of the protected variable$table.
Q89. What are Requests in Laravel?
Requests in Laravel are a way to interact with incoming HTTP requests along with sessions, cookies, and even files if submitted with the request.
When any request is submitted to a laravel route, it goes through to the controller method, and with the help of dependency Injection, the request object is available within the method.
We can do all kinds of things with the request like validating or authorizing the request.
Illuminate\Http\Request.
Q90. Explain the concept of cookies?
A cookie is a small record that the server installs on the client’s computer. They store data about a user on the browser. It is used to identify a user and is embedded on the user’s computer when they request a particular page. Each time a similar PC asks for a page with a program, it will send the cookie as well.
Cookie can be created by global cookie helper of Laravel. It is an instance of Symfony\Component\HttpFoundation\Cookie.
// Set Cookie
public function setCookie(Request $request) {
Q91. Inbuilt Authentication Controllers of Laravel?
LoginController
RegisterController
ResetPasswordController
ForgetPasswordController
Q92. What is collections in Laravel?
Collections is a wrapper class to work with arrays.
Laravel Eloquent queries use a set of the most common functions to return database result.
Q93. What is dependency Injection in Laravel?
In Laravel, dependency injection is the process of injecting class dependencies into a class through a constructor or setter method.
This allows your code to look clean and run faster.
In simple words we can say that, when a class depends on another class, or we can say when we use a class object into another class than it is called Dependancy Injection.
So for remove this dependancy we use some technique, like Interface or Constructor or Setter or something eles.
Q94. What are queues in Laravel?
Queues are a way to run tasks in the background.
Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database.
Queues allow you to delay the processing of a time consuming task, such as sending an email, until a later time.
For example: Sending an email is a time-consuming task, so what we will do is we will create a job that’s the only task is to send an email to the user in the background.
To create a Job, laravel provides a Queue API. So Queues are a way to run tasks in the background.
Q95. What are accessors and mutators?
Laravel Accessors and Mutators are custom, user defined methods.
Accessors are used to format the attributes when you retrieve them from database. Whereas, Mutators are used to format the attributes before saving them into the database.
// Accessors
public function getFullNameAttribute()
{
return "{$this->first_name} {$this->last_name}"; // With the help of $user->full_name we'll get the full name
}
// Mutators
public function setFirstNameAttribute($value)
{
$this->attributes[‘first_name’] = ucfirst($value); // First name First word to be capitalized before saving it to the database
}
Q96. What is Ajax in Laravel?
Ajax stands for Asynchronous JavaScript and XML is a web development technique that is used to create asynchronous Web applications.
In Laravel, response() and json() functions are used to create asynchronous web applications.
Q97. How to rollback last migration?
Use need to use artisan command to rollback the last migration.
php artisan migrate:rollback --path=...
Q98. what is open source software?
Open-source software is a software which source code is freely available. The source code can be shared and modified according to the user requirement.
Q99. How to generate a request in Laravel?
Using below command:
php artisan make:request UploadFileRequest
Q100. What is the artisan command used to get a list of available commands?
Using below command:
php artisan list
Q101. How can you run Laravel Project?
Using below command:
php artisan serve
Cookie Policy
This website uses cookie or similar technologies, to enhance your browsing experience and provide personalised recommendations. By continuing to use our website, you agree to our Cookie Policy.