I want to refactor my Controller code which is creating a new record at table products:
public function store(Request $request)
{
$newPro = Product::create([
'name' => $request->product_name,
'en_name' => $request->product_name_english,
'type' => $request->product_type,
'cat_id' => $request->category_product,
]);
...
}
Now in order to refactor this code, I have two options:
1- Create a separate method at the same Controller and then call it like this:
$newPro = self::createProduct($request->product_name,$request->product_name_english,$request->product_type,$request->category_product)
2- Create a separate Class and call it by the interface or facade (Best way)
Now I wanted to use the 2nd option but I don't know really how to!
So if you know please let me know...