action = $action; $this->request = $request; $this->model = $transactions_detail; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(TransactionsDetail $transactions_detail, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $transactions_detail = $transactions_detail->create($attributes); return $transactions_detail; } public function update(TransactionsDetail $transactions_detail, array $request) { $attributes = $request; $transactions_detail->update($attributes); return $transactions_detail; } public function destroy(TransactionsDetail $transactions_detail, array $request) { $transactions_detail->delete(); return $transactions_detail; } public function copy(TransactionsDetail $transactions_detail, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $transactions_detail = $transactions_detail->replicate(); $transactions_detail->created_at = Carbon::now(); $transactions_detail->save(); return $transactions_detail; } for ($i = 1; $i <= $count; $i++) { $new = $transactions_detail->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $transactions_detail; } }