Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Apr 25, 2024
1 parent 5f2e2cf commit 29b2ea6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Dashboard;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreUrl;
use App\Http\Requests\UpdateUrlRequest;
use App\Models\Url;
use Illuminate\Support\Facades\Gate;

Expand Down Expand Up @@ -37,13 +37,13 @@ public function edit(Url $url)
/**
* Update the destination URL
*
* @param StoreUrl $request \App\Http\Requests\StoreUrl
* @param Url $url \App\Models\Url
* @param UpdateUrlRequest $request \App\Http\Requests\UpdateUrlRequest
* @param Url $url \App\Models\Url
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function update(StoreUrl $request, Url $url)
public function update(UpdateUrlRequest $request, Url $url)
{
$url->update([
'destination' => $request->long_url,
Expand Down
33 changes: 33 additions & 0 deletions app/Http/Requests/UpdateUrlRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Requests;

use App\Models\Url;
use App\Rules\Url\DomainBlacklist;
use Illuminate\Foundation\Http\FormRequest;

class UpdateUrlRequest 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
{
$titleLength = Url::TITLE_LENGTH;

return [
'title' => ["max:{$titleLength}"],
'long_url' => ['required', 'url', 'max:65535', new DomainBlacklist],
];
}
}

0 comments on commit 29b2ea6

Please sign in to comment.