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