/** * Store a newly created WorkFlow in database * */ public function store(WorkFlowRequest $request) { $input = $request->all(); $workflow = new Work_flow($input); // If the new WorkFlow is to be the default one if ($workflow->default == 1) { // Set all others existing as not being default in database $workflows = Work_flow::all(); foreach ($workflows as $workflw) { $workflw->default = 0; $workflw->update(); } } // save new WorkFlow $workflow->save(); return redirect('workflow/create'); }