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