File manager - Edit - /var/www/html/portal/app/Http/Requests/Comunicacao/NoticiaRequest.php
Back
<?php namespace App\Http\Requests\Comunicacao; use Illuminate\Foundation\Http\FormRequest; use App\Http\Controllers\Controller; use Illuminate\Support\Str; class NoticiaRequest extends FormRequest { /** * Determine if the user is authorized to make this request. */ public function authorize(): bool { return true; } /** * Get the validation rules that apply to the request. * * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> */ public function rules(): array { if (isset($this->id) && $this->route()->action["as"] == "admin.noticias.update") { return [ 'slug' => 'required|max:255', 'title' => 'required|max:255', 'summary' => 'required|max:500', 'description' => 'required', 'featuredPhoto' => 'nullable|image|mimes:jpeg,jpg,png,gif|mimetypes:image/jpeg,image/png,image/gif', 'internalPhoto' => 'nullable|image|mimes:jpeg,jpg,png,gif|mimetypes:image/jpeg,image/png,image/gif', ]; } else { return [ 'slug' => 'required|max:255', 'title' => 'required|max:255', 'summary' => 'required|max:500', 'description' => 'required', 'featuredPhoto' => 'nullable|image|mimes:jpeg,jpg,png,gif|mimetypes:image/jpeg,image/png,image/gif', 'internalPhoto' => 'nullable|image|mimes:jpeg,jpg,png,gif|mimetypes:image/jpeg,image/png,image/gif', ]; } } public function messages(): array { return [ "slug.required" => __("* Não foi possível criar uma URL amigável!"), "slug.max" => __("* A URL amigável excedeu o limite de 255 caracteres!"), "title.required" => __("* O título da notícia é obrigatório!"), "title.max" => __("* O título da notícia excedeu o limite de 255 caracteres!"), "summary.required" => __("* O resumo da notícia é obrigatório"), "summary.max" => __("* O resumo da notícia excedeu o limite de 500 caracteres!"), "description.required" => __("* O corpo da notícia é obrigatório!"), "featuredPhoto.required" => __("* A foto destaque da notícia é obrigatória!"), "featuredPhoto.image" => __("* Por favor selecione uma foto destaque para a notícia!"), "featuredPhoto.mimes" => __("* Os formatos de imagens permitido são: jpeg,jpg,png,gif!"), "featuredPhoto.mimetypes" => __("* Os formatos de imagens permitido são: jpeg,jpg,png,gif!"), "internalPhoto.required" => __("* A foto interna da notícia é obrigatória!"), "internalPhoto.image" => __("* Por favor selecione uma foto interna para a notícia!"), "internalPhoto.mimes" => __("* Os formatos de imagens permitido são: jpeg,jpg,png,gif!"), "internalPhoto.mimetypes" => __("* Os formatos de imagens permitido são: jpeg,jpg,png,gif!"), ]; } protected function prepareForValidation(): void { $implode = null; if (isset($this->cloud)) { foreach ($this->cloud as $name => $value) { $implode[] = $value; } $implode = implode(",", $implode); } $implode_tags = null; if (isset($this->tags)) { foreach ($this->tags as $name => $value) { $implode_tags[] = $value; } $implode_tags = implode(",", $implode_tags); } (isset($this->fix) && $this->fix == "on") ? $bool = 1 : $bool = 0; $Controller = new Controller(); $this->merge([ 'slug' => Str::slug($this->title), 'cloud' => $implode, 'tags' => $implode_tags, // 'description' => $Controller->removeHtmlAttributesRegex($this->description), 'description' => $this->description, // 'summary' => $Controller->removeHtmlAttributesRegex($this->summary), 'summary' => $this->summary, 'fix' => $bool, ]); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings