How can we create a record in Laravel using eloquent?

0 votes
How can i create the record in laravel?
Mar 20 in Laravel by kartik
• 20,270 points
62 views

1 answer to this question.

0 votes

We need to create a new model instance if we want to create a new record in the database using Laravel eloquent. Then we are required to set attributes on the model and call the save() method.

Example:

                    public functionsaveProduct(Request $request )  

                     $product = new product;  

                     $product->name = $request->name;  

                     $product->description = $request->name;  

                      $product->save();  
answered Mar 20 by Niroj
• 43,100 points

Related Questions In Laravel

0 votes
1 answer

How can we generate migration in Laravel?

Hello, Migrations are like version control for your database, ...READ MORE

answered Mar 19 in Laravel by Niroj
• 43,100 points
43 views
0 votes
1 answer

How can we use the custom table in Laravel?

Hey, We can easily use custom table in ...READ MORE

answered Mar 20 in Laravel by Niroj
• 43,100 points
56 views
0 votes
1 answer

How can we check the logged-in user info in Laravel?

Hey @kartik, yes we can keep track of ...READ MORE

answered Mar 20 in Laravel by Niroj
• 43,100 points
58 views
0 votes
1 answer

How can we Create custom name while uploading image using storage?

Hello, You also can do like this $ImgValue ...READ MORE

answered Mar 26 in Laravel by Niroj
• 43,100 points
31 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17 in Laravel by Niroj
• 43,100 points
118 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 43,100 points
121 views
0 votes
1 answer

Display Laravel in browser by using cmd promt?

Hello, First you need to have laravel install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 43,100 points
42 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17 in Laravel by Niroj
• 43,100 points
54 views
0 votes
1 answer

How can we Create Multiple Where Clause Query Using Laravel Eloquent?

Hii, You can use Conditions using Array: $users = User::where([ ...READ MORE

answered Mar 30 in Laravel by Niroj
• 43,100 points
1,135 views
0 votes
1 answer

What is middleware? How can we register middeleware in Laravel?

Middleware acts as a bridge between a ...READ MORE

answered Mar 18 in Laravel by Niroj
• 43,100 points
198 views