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