app/Http/Controllers/CategoryGroupController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\CategoryGroup  $categoryGroup
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(CategoryGroupRequest $request, CategoryGroup $categorygroup)
    {
        $this->validate($request, [
            'category_group_code' => 'required',
            'category_group_desc' => 'required',
        ]);
        $prev_value_category_group_code = $request->input('prev_value_category_group_code');
        $prev_value_category_group_desc = $request->input('prev_value_category_group_desc');
        $category_group_code = $request->input('category_group_code');
        $category_group_desc = $request->input('category_group_desc');
        $categorygroup = CategoryGroup::find($categorygroup->id);
        $categorygroup->category_group_code = $category_group_code;
        $categorygroup->category_group_desc = $category_group_desc;
        $categorygroup->save();
        $audittrails = AuditTrail::create([
            'user_id' => $request->input('user_id'),
            'action' => $request->input('action'),
            'remarks' => "Updated a record from the fields of <font class='text-danger'>$prev_value_category_group_code</font> to <font class='text-success'>$category_group_code</font> and <font class='text-danger'>$prev_value_category_group_desc</font> to <font class='text-success'>$category_group_desc</font>"
        ]);
        return redirect()->route('c4s category group')->withStatus(__('Category Group Successfully Updated.'));
    }
public function update ( CategoryGroupRequest $ request , CategoryGroup $ categorygroup ) { $ this -> validate ( $ request , [ 'category_group_code' => 'required' , 'category_group_desc' => 'required' , ] ) ; $ prev_value_category_group_code = $ request -> input ( 'prev_value_category_group_code' ) ; $ prev_value_category_group_desc = $ request -> input ( 'prev_value_category_group_desc' ) ; $ category_group_code = $ request -> input ( 'category_group_code' ) ; $ category_group_desc = $ request -> input ( 'category_group_desc' ) ; $ categorygroup = CategoryGroup :: find ( $ categorygroup -> id ) ; $ categorygroup -> category_group_code = $ category_group_code ; $ categorygroup -> category_group_desc = $ category_group_desc ; $ categorygroup -> save ( ) ; $ audittrails = AuditTrail :: create ( [ 'user_id' => $ request -> input ( 'user_id' ) , 'action' => $ request -> input ( 'action' ) , 'remarks' => " Updated a record from the fields of <font class='text-danger'> $ prev_value_category_group_code </font> to <font class='text-success'> $ category_group_code </font> and <font class='text-danger'> $ prev_value_category_group_desc </font> to <font class='text-success'> $ category_group_desc </font> " ] ) ; return redirect ( ) -> route ( 'c4s category group' ) -> withStatus ( __ ( 'Category Group Successfully Updated.' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .