In this test, you will have to fulfill several tasks, by fully respecting the requirements and restrictions.
The application consists of only one page accessible at http://test.local/.
On that page a fully functional filtering of App\Post records is implemented by using the App\Repositories\EloquentPostSearchRepository.php repository class.
3-5 hours
- Clone this repository
- Copy the contents of
.env.exampleinto your.envfile - Apply the other usual Laravel installation steps
- Your application should be available at
http://neurony-test.local
- Create a
PostFactoryclass - Modify the
DatabaseSeederclass to seed 3 users and 50 posts
As already, mentioned this application filters App\Post records by using the App\Repositories\EloquentPostSearchRepository class.
You will have to change this filtering logic to work with Elasticsearch.
Requirements
- In
App\Http\Controllers\IndexController, replaceEloquentPostSearchRepositorywithSearchableContract(https://www.screencast.com/t/GwQbtBCq) - Create a new repository class called
App\Repositories\ElasticearchPostSearchRepositoryand in here write the code for filtering the records - The
Elasticsearch indexshould be calledtest
Restrictions
- Besides the change mentioned above, you are not allowed to alter the
App\Http\Controllers\IndexControllerclass in any other way.
This task is considered complete when the user is able to filter posts in exactly the same way as before, but using Elasticsearch.
Now that your filtering with Elasticsearch is complete, it's time to notify every seeded user (Task 1) each time a search happens.
Requirements
- Use Laravel's notifications system to send notifications only via
database. - Alter the
notificationstable and add a new column calledcount. - Your
App\Repositories\ElasticearchPostSearchRepositoryshould use theApp\Traits\NotifiesPostSearchestrait. - Send a
App\Notifications\NewPostSearchnotification to all users every time a search happens. - The
datacolumn in thenotificationstable should contain only the subject of the notification and an array containing the ids of posts resulted from the respective search criteria - The
countcolumn in thenotificationstable should contain the count of posts the respective search returned
Restrictions
- You are not allowed to modify the
App\Traits\NotifiesPostSearchestrait at all. - You are not allowed to modify the
App\Contracts\SearchableContractinterface at all. - Your
App\Repositories\ElasticearchPostSearchRepositoryclass should directly implement ALL required methods. - For sending notifications, you should use the
sendNewPostSearchNotificationsmethod from theApp\Traits\NotifiesPostSearchestrait and not the one from the interface (seeApp\Providers\EventServiceProvider).
This task is considered complete when after a search is performed on the site, a new notification is inserted in the notifications database table for each user.
The notification should respect the format with an extra column.