From faacca7d009e1da088de1105c77dc8c74ec562d4 Mon Sep 17 00:00:00 2001 From: Egoist Date: Tue, 11 Apr 2023 12:04:41 +0300 Subject: [PATCH] Update create URL request --- README.md | 20 ++++++++++++++++++++ src/Http/Requests/CreateShortUrlRequest.php | 14 +++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7d23868..b276e2e 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,26 @@ $shortUrl = UrlShortener::shortUrl( ); ``` +### CreateShortUrlRequest + +```php +use LaravelReady\UrlShortener\Requests\CreateShortUrlRequest; + +class ShortUrlController extends Controller +{ + public function store(CreateShortUrlRequest $request) + { + $validateData = $request->validated(); + + $shortUrl = UrlShortener::shortUrl( + $validateData['url'], + $validateData['meta'] ?? [], + $validateData['type'] ?? ShortingType::Random + ); + } +} +``` + ## âš“Credits - This project was generated by the **[packager](https://github.com/laravel-ready/packager)**. diff --git a/src/Http/Requests/CreateShortUrlRequest.php b/src/Http/Requests/CreateShortUrlRequest.php index 4376969..6c26faf 100644 --- a/src/Http/Requests/CreateShortUrlRequest.php +++ b/src/Http/Requests/CreateShortUrlRequest.php @@ -1,6 +1,6 @@ 'required|url', 'type' => 'required|in:random,custom,emoji_random,emoji_custom', - 'title' => 'nullable|string|min:3|max:200', - 'description' => 'nullable|string|min:3|max:1000', - 'status' => 'nullable|boolean', - 'delay' => 'nullable|integer|min:0|max:1000', - 'expire_date' => 'nullable|date_format:Y-m-d H:i:s|after_or_equal:' . date(DATE_ATOM), - 'password' => 'nullable|string|min:3|max:100', + 'meta.title' => 'nullable|string|min:3|max:200', + 'meta.description' => 'nullable|string|min:3|max:1000', + 'meta.status' => 'nullable|boolean', + 'meta.delay' => 'nullable|integer|min:0|max:1000', + 'meta.expire_date' => 'nullable|date_format:Y-m-d H:i:s|after_or_equal:' . date(DATE_ATOM), + 'meta.password' => 'nullable|string|min:3|max:100', ]; } }