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