Skip to content

Commit

Permalink
Validate string type for search input
Browse files Browse the repository at this point in the history
  • Loading branch information
betsyecastro committed Dec 9, 2024
1 parent 33664ba commit 0b5983d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/ProfilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Helpers\Contracts\LdapHelperContract;
use App\Http\Requests\ProfileBannerImageRequest;
use App\Http\Requests\ProfileImageRequest;
use App\Http\Requests\ProfileSearchRequest;
use App\Http\Requests\ProfileUpdateRequest;
use App\School;
use Illuminate\Contracts\View\View as ViewContract;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function __construct()
/**
* Display a listing of profiles.
*/
public function index(Request $request): View|ViewContract|RedirectResponse
public function index(ProfileSearchRequest $request): View|ViewContract|RedirectResponse
{
$search = $request->input('search');

Expand Down
37 changes: 37 additions & 0 deletions app/Http/Requests/ProfileSearchRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ProfileSearchRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
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
{
return [
'search' => 'string',
];
}

public function messages()
{
return [
'search.string' => 'The search value must be a string',
];
}
}
2 changes: 1 addition & 1 deletion resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1 class="sr-only">Profiles</h1>
@stop
@section('content')

@include('errors.has')
@if(File::exists(public_path('/storage/video/home.jpg')) && File::exists(public_path('/storage/video/home.mp4')))
<div class="video-cover">
<button class="video-control play-pause" aria-controls="home-video" aria-pressed="true">
Expand Down

0 comments on commit 0b5983d

Please sign in to comment.