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