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