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