Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

Insert query in Laravel 5 using Model

by
Category:laravel
mysql laravel
Insert query in Laravel 5 using Model

How to model through data inser in database using laravel 5.

Now you can use model in your controllers.

use App\SearchLog;

Insert data to database table using model.

$searchlog = new SearchLog;
$searchlog->user_id = Auth::user()->id;
$searchlog->min_carat = $request->min_carat;
$searchlog->max_carat = $request->max_carat;
$searchlog->min_depth = $request->min_depth;
$searchlog->max_depth = $request->max_depth;
$searchlog->min_price = $request->min_price;
$searchlog->max_price = $request->max_price;
if(!empty($request->shape))
{	
	$searchlog->shape = $request->shape;
}
if(!empty($request->color))
{	
	$searchlog->color = $request->color;
}
if(!empty($request->clarity))
{	
	$searchlog->clarity = $request->clarity;
}
if(!empty($request->cut))
{	
	$searchlog->cut = $request->cut;
}
if(!empty($request->polish))
{	
	$searchlog->polish = $request->polish;
}
if(!empty($request->symmetry))
{	
	$searchlog->symmetry = $request->symmetry;
}
if(!empty($request->flourescence))
{	
	$searchlog->flourescence = $request->flourescence;
}
$searchlog->save();

0 Comments


Html code work in comment box


Related Post