This repo was made to showcase the GovAssist challenge
-
Create a Url model with the following properties:
a. Id b. destination (string): it will contain the long url c. slug (string): it will contain the slug of the shortened url. d. timestamps (created_at, updated_at)
-
Add a model accessor to the model above to retrieve the full shortened URL as an attribute and make sure this attribute is appended to the model whenever it is retrieved.
-
Create a migration for the model above.
-
Implement an auth system for login and registration.
-
Create a form that will only be accessible for registered and logged in users.
-
Create an input text field for the “destination” or long-url and a submit button.
-
Add validations to the form so it will not allow the text field to be “empty” and to only allow valid urls.
-
The form once valid and submitted, it should store the destination url in the DB using the Url model. It is also required to generate a 5 characters long random string that will be used as the “slug” property.
-
Create the routes needed and make use of model binding for them when applicable (for Url model).
-
Make sure that the route that will redirect the shortened url to the actual long-url is created.
-
Use of laravel helpers are encouraged.
-
Create a simple POST REST API endpoint that takes “destination” as a required property of the request body. If no “destination” is provided then it should return a validation error. The same is applied for when a non-valid url is provided. Sample of valid payload for the endpoint:
{ "destination": "https://google.com"}
Expected json response on success:
{ "destination": "https://google.com", "slug": "k9GZw", "updated_at": "2021-09-10T23:52:11.000000Z", "created_at": "2021-09-10T23:52:11.000000Z", "id": 18, "shortened_url": "http://url-shortener.test/k9GZw" }
-
Make sure to use a git repository (either bitbucket or github) to store the code of your application. Then share the url of the repository with us. Make sure the repository is public.
-
Laravel scaffolding is welcomed (and encouraged).
- Using a random 5 letter string for the url slugs might lead to collisions
- Stick as close as possible to PSR-12
- Use guard clauses whenever possible
- Design a clean, sleek interface
- Write clean code that is easy to understand & extend
- Install the npm and composer dependencies
- Run the migrations
- Configure your env
- Run
npm run prod