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