/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { try { $response = ['log' => []]; $statusCode = 200; $log = Activity_log::find($id); $user = User::find($log->user_id); $response = ['id' => $log->id, 'activity' => $log->activity, 'user' => $user->name . ", " . $user->full_name, 'created_at' => $log->created_at]; } catch (Exception $e) { $statusCode = 404; } finally { return Response::json($response, $statusCode); } }
public function logActivity(User $payer, $payee, $txn_currency_id, $amount_in_txn_currency) { try { $activity = Activity_log::create(['id' => (string) Uuid::generate(4), 'payer_id' => $payer->id, 'payee_id' => $payee->user->id, 'txn_currencyid' => 2, 'amount_in_txn_currency' => $amount_in_txn_currency, 'number_of_kudos' => Currency::findOrFail($txn_currency_id)->Kudos_exchange * $amount_in_txn_currency]); session()->flash('flash_message', 'Activity logged'); return $activity->id; } catch (Exception $e) { session()->flash('flash_message', 'Error in activity logging'); return FALSE; } }