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