Skip to content

Instantly share code, notes, and snippets.

@timothymarois
Last active September 7, 2023 14:14
Show Gist options
  • Save timothymarois/c9a6f64c8f844296b6a628d24147513e to your computer and use it in GitHub Desktop.
Save timothymarois/c9a6f64c8f844296b6a628d24147513e to your computer and use it in GitHub Desktop.
Laravel Test Assessment (1)

For this assessment, you can create a new laravel project and either post it on github or a local zip

1) Routes, Models, Controllers

  • Create a route for POST -> /api/campaign/create
  • Create a controller for CampaignController.php with the API resource methods
  • Create a model for campaigns table and update the campaign controller to create, update, and delete
  • Within CampaignController create method for index and query the campaign model for status = active return the results
  • Create a database migration for the campaigns table

Campaigns table:

  • id
  • name
  • order (int)
  • type
  • status
  • start_date

2) Query

Active Campaigns:

You can either do this in a service method or model, but write a query within a method called findActiveCampaigns and return results from the following query:

  • status = active
  • type != rvm
  • order by order field descending
  • Only return 10 items

3) Bulk Update

Each Campaign needs to be updated

You can write this as a database migration.

There are 100 million rows in the database, and you need to update all of them with the following logic:

  • For each campaign, you need ot run this method and update the campaign start_date with the date returned from this method:
  • $startDate = CampaignService::filter()->requestStartDate($campaignId);

Note: the php script has no timeout, so how ever long it takes for the query to run is not relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment