Skip to content

Commit

Permalink
Update create URL request
Browse files Browse the repository at this point in the history
  • Loading branch information
relliv committed Apr 11, 2023
1 parent 18a5cfb commit faacca7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**.
Expand Down
14 changes: 7 additions & 7 deletions src/Http/Requests/CreateShortUrlRequest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Requests\Api;
namespace LaravelReady\UrlShortener\Requests;

use Illuminate\Foundation\Http\FormRequest;

Expand All @@ -21,12 +21,12 @@ public function rules()
return [
'url' => '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',
];
}
}

0 comments on commit faacca7

Please sign in to comment.