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