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