app/Http/Controllers/ExpenseController.php
/**
     * Update the specified resource in storage.
     *
     * @param Request $request
     * @param Expense $expense
     * @return JsonResponse
     */
Update the specified resource in storage.
@param Request $request
@param Expense $expense
@return JsonResponse
Update the specified resource in storage . @param Request $request @param Expense $expense @return JsonResponse
public function update(Request $request, Expense $expense)
    {
        $request->validate(
            [
                'branch_id' => 'nullable|exists:branches,id',
                'amount' => 'nullable|numeric',
                'reason' => 'nullable'
            ]
        );
        $data['branch_id'] = $request->branch_id ? $request->branch_id : $expense->branch_id;
        $data['amount'] = $request->amount ? $request->amount : $expense->amount;
        $data['reason'] = $request->reason ? $request->reason : $expense->reason;
        if ($expense->update($data))
            return Helper::response_with_data(Expense::query()->find($expense->id), false);
        return Helper::response_with_data(null, true);
    }
public function update ( Request $ request , Expense $ expense ) { $ request -> validate ( [ 'branch_id' => 'nullable|exists:branches,id' , 'amount' => 'nullable|numeric' , 'reason' => 'nullable' ] ) ; $ data [ 'branch_id' ] = $ request -> branch_id ? $ request -> branch_id : $ expense -> branch_id ; $ data [ 'amount' ] = $ request -> amount ? $ request -> amount : $ expense -> amount ; $ data [ 'reason' ] = $ request -> reason ? $ request -> reason : $ expense -> reason ; if ( $ expense -> update ( $ data ) ) return Helper :: response_with_data ( Expense :: query ( ) -> find ( $ expense -> id ) , false ) ; return Helper :: response_with_data ( null , true ) ; }
Update the specified resource in storage.
Update the specified resource in storage .