コード例 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $expense = Expense::findOrFail($id);
     $expense->fill($request->all());
     $expense->save();
     //return ['Success' => 'ok', 'Expense' => $expense];
 }
コード例 #2
0
 public function update(EditExpenseRequest $request, $id)
 {
     $id_user = Auth::user()->id;
     $expenses = Expense::findOrFail($id);
     $expenses->iduser_update->{$id_user};
     $expenses->fill($request->all());
     $expenses->save();
     Session::flash('message', ' Se actualizo exitosamente');
     return redirect()->back();
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $expense = Expense::findOrFail($id);
         $expense->delete();
     } catch (ModelNotFoundException $e) {
         Log::error($e->getMessage());
         Log::info('Modelo no encontrado');
         return response()->make('Model not found', 400);
     }
 }
コード例 #4
0
ファイル: Capital.php プロジェクト: shiruken1/LEIAs
 /**
  * Get who it's tied to in one shot
  *
  * @return array[0] the amount or Carbon date by which this capital is set to begin
  * @return array[1] the Income or Expense object
  **/
 public function endsWhen()
 {
     $ends = (string) $this->end_at . '_end';
     $object = FALSE;
     if ($this->end_at === 'income') {
         $object = Income::findOrFail($this->income_end_id);
     }
     if ($this->end_at === 'expenses') {
         $object = Expense::findOrFail($this->expenses_end_id);
     }
     return array($object, $this->{$ends});
 }
コード例 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     // Save the updated expense
     $expense = Expense::findOrFail($id);
     $expense->base_amount = $request->get('base_amount');
     $expense->description = $request->get('description');
     $expense->save();
     // construct and save the expense supplements
     if ($request->has('name')) {
         $supplements = $this->parseSupplements($request);
         // now we save the models to the database
         foreach ($supplements as $id => $supplement) {
             $result = ExpenseSupplement::find($id);
             if ($result instanceof ExpenseSupplement) {
                 $result->update($supplement);
             } else {
                 $expense->supplements()->create($supplement);
             }
         }
     }
     // all saved and good to go
     return redirect()->back()->with('success', 'Expense note saved');
 }
コード例 #6
0
 /**
  * Deletes an expense
  *
  * @param $id
  *
  * @return array
  */
 public function delete($id)
 {
     $expense = $this->expense->findOrFail($id);
     $expense->delete($id);
 }
コード例 #7
0
ファイル: ExpenseController.php プロジェクト: shiruken1/LEIAs
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $expense = Expense::findOrFail($id);
     $expense->delete();
     return redirect()->route('expenses.index')->with('message', 'Item deleted successfully.');
 }