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