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