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