how-to-call-function-from-same-controller-in-laravel
how-to-call-function-from-same-controller-in-laravel
how-to-use-attempt-in-laravel
First Method
$colorCode = $this->getColorCode('red');
Second Method
$printReport = new PrintReportController;
$prinReport->getPrintReport();
Full Code
public function index(Request $request)
{
$colorCode = $this->getColorCode('red');
$post = Post::create([
'name' => 'Silver',
'stock' => 100,
'bg_color' => $colorCode
]);
dd($post);
}
/**
* Write code on Method
*
* @return response()
*/
pivate function getColorCode($colorName)
{
$colors = [
'pink' => '#FFC0CB',
'plum' => '#DDA0DD',
'powderblue' => '#B0E0E6',
'purple' => '#800080',
'red' => '#FF0000',
];
return $colors[$colorName];
}
Top comments (0)