Skip to content

Commit

Permalink
Merge pull request #23 from karlomikus/develop
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
karlomikus committed Nov 26, 2022
2 parents 078c2ca + bc5e9be commit bebb9bb
Show file tree
Hide file tree
Showing 39 changed files with 1,110 additions and 113 deletions.
2 changes: 2 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ DB_DATABASE=":memory:"
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://localhost:7700
MEILISEARCH_KEY=masterKey

SPEC_PATH=./docs
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.5.3
- Update OpenApi spec and endpoints
- Delete responses now return 204
- Add contract testing
- Update related ingredients

# v0.5.2
- Add response caching, disabled by default
- Cache docker image steps in GH actions
Expand Down
22 changes: 11 additions & 11 deletions app/Console/Commands/OpenBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function handle()
Ingredient::create(['name' => 'Vanilla Extract', 'ingredient_category_id' => $uncategorized->id, 'strength' => 0.0, 'description' => 'Solution made by macerating and percolating vanilla pods in a solution of ethanol and water.', 'user_id' => 1]);

// Bitters
Ingredient::create(['name' => 'Orange bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 28.0, 'description' => 'Orange bitters is a form of bitters, a cocktail flavoring made from such ingredients as the peels of Seville oranges, cardamom, caraway seed, coriander, anise, and burnt sugar in an alcohol base.', 'origin' => 'Worldwide', 'user_id' => 1]);
Ingredient::create(['name' => 'Angostura aromatic bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 44.7, 'description' => 'Angostura bitters is a concentrated bitters (herbal alcoholic preparation) based on gentian, herbs, and spices, by House of Angostura in Trinidad and Tobago.', 'origin' => 'Trinidad & Tobago', 'user_id' => 1]);
Ingredient::create(['name' => 'Peach bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 35.0, 'description' => 'Peach bitters flavored with peaches and herbs.', 'origin' => 'Worldwide', 'user_id' => 1]);
Ingredient::create(['name' => 'Angostura cocoa bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 38.0, 'description' => 'Top notes of rich bitter, floral, nutty cocoa with a bold infusion of aromatic botanicals provide endless possibilities to remix classic cocktails.', 'origin' => 'Trinidad & Tobago', 'user_id' => 1]);
Ingredient::create(['name' => 'Peychauds Bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 35.0, 'description' => 'It is a gentian-based bitters, comparable to Angostura bitters, but with a predominant anise aroma combined with a background of mint.', 'origin' => 'North America', 'user_id' => 1]);
Ingredient::create(['name' => 'Orange bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 28.0, 'color' => '#ed8300', 'description' => 'Orange bitters is a form of bitters, a cocktail flavoring made from such ingredients as the peels of Seville oranges, cardamom, caraway seed, coriander, anise, and burnt sugar in an alcohol base.', 'origin' => 'Worldwide', 'user_id' => 1]);
Ingredient::create(['name' => 'Angostura aromatic bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 44.7, 'color' => '#e95310', 'description' => 'Angostura bitters is a concentrated bitters (herbal alcoholic preparation) based on gentian, herbs, and spices, by House of Angostura in Trinidad and Tobago.', 'origin' => 'Trinidad & Tobago', 'user_id' => 1]);
Ingredient::create(['name' => 'Peach bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 35.0, 'color' => '#ca7c00', 'description' => 'Peach bitters flavored with peaches and herbs.', 'origin' => 'Worldwide', 'user_id' => 1]);
Ingredient::create(['name' => 'Angostura cocoa bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 38.0, 'color' => '#894c36', 'description' => 'Top notes of rich bitter, floral, nutty cocoa with a bold infusion of aromatic botanicals provide endless possibilities to remix classic cocktails.', 'origin' => 'Trinidad & Tobago', 'user_id' => 1]);
Ingredient::create(['name' => 'Peychauds Bitters', 'ingredient_category_id' => $bitters->id, 'strength' => 35.0, 'color' => '#622426', 'description' => 'It is a gentian-based bitters, comparable to Angostura bitters, but with a predominant anise aroma combined with a background of mint.', 'origin' => 'North America', 'user_id' => 1]);

// Liqueurs
Ingredient::create(['name' => 'Campari', 'ingredient_category_id' => $liqueurs->id, 'strength' => 25.0, 'description' => 'Italian alcoholic liqueur obtained from the infusion of herbs and fruit.', 'color' => '#ca101e', 'origin' => 'Italy', 'user_id' => 1]);
Expand All @@ -159,10 +159,8 @@ public function handle()
Ingredient::create(['name' => 'Crème de cassis (blackcurrant liqueur)', 'ingredient_category_id' => $liqueurs->id, 'strength' => 25.0, 'description' => 'It is made from blackcurrants that are crushed and soaked in alcohol, with sugar subsequently added.', 'color' => '#282722', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Crème de Violette', 'ingredient_category_id' => $liqueurs->id, 'strength' => 16.0, 'description' => 'Crème de violette is a delicate, barely-sweet liqueur made from violet flower petals.', 'color' => '#a5a2fd', 'origin' => 'Worldwide', 'user_id' => 1]);
Ingredient::create(['name' => 'Crème de mûre (blackberry liqueur)', 'ingredient_category_id' => $liqueurs->id, 'strength' => 42.3, 'description' => 'Crème de mûre is a liqueur made with fresh blackberries.', 'color' => '#5f1933', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Cointreau', 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Orange-flavoured triple sec liqueur.', 'color' => '#ffffff', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Grand Marnier', 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Orange-flavored liqueur made from a blend of Cognac brandy, distilled essence of bitter orange, and sugar.', 'color' => '#f34e02', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Suze', 'ingredient_category_id' => $liqueurs->id, 'strength' => 15.0, 'description' => 'Bitter flavored drink made with the roots of the plant gentian.', 'color' => '#ffffff', 'origin' => 'Switzerland', 'user_id' => 1]);
Ingredient::create(['name' => 'Triple Sec', 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Triple sec is usually made from orange peels steeped in a spirit derived from sugar beet due to its neutral flavor. Oranges are then harvested when their skin is still green and they have not fully ripened, so the essential oils remain in the skin and not the flesh of the fruit. This spirit is then redistilled and mixed with more neutral spirit, water, and powdered beet sugar resulting in the final liqueur. This process creates a spirit that has a very strong and distinct orange flavor.', 'color' => '#ffffff', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Maraschino', 'ingredient_category_id' => $liqueurs->id, 'strength' => 32.0, 'description' => 'Liqueur obtained from the distillation of Marasca cherries. The small, slightly sour fruit of the Tapiwa cherry tree, which grows wild along parts of the Dalmatian coast in Croatia, lends the liqueur its unique aroma.', 'color' => '#ffffff', 'origin' => 'Croatia', 'user_id' => 1]);
Ingredient::create(['name' => 'Galliano', 'ingredient_category_id' => $liqueurs->id, 'strength' => 42.3, 'description' => 'Galliano is sweet with vanilla-anise flavour and subtle citrus and woodsy herbal undernotes.', 'color' => '#caa701', 'origin' => 'Italy', 'user_id' => 1]);
Ingredient::create(['name' => 'Chambord', 'ingredient_category_id' => $liqueurs->id, 'strength' => 16.5, 'description' => 'Raspberry liqueur modelled after a liqueur produced in the Loire Valley of France during the late 17th century.', 'color' => '#6f1123', 'origin' => 'Worldwide', 'user_id' => 1]);
Expand All @@ -180,9 +178,11 @@ public function handle()
Ingredient::create(['name' => 'Baileys Irish Cream', 'ingredient_category_id' => $liqueurs->id, 'strength' => 17.0, 'description' => 'Baileys Irish Cream is an Irish cream liqueur, an alcoholic drink flavoured with cream, cocoa and Irish whiskey. It is made by Diageo at Nangor Road, in Dublin, Ireland and in Mallusk, Northern Ireland. It is the original Irish cream, invented by a team headed by Tom Jago in 1971 for Gilbeys of Ireland.', 'origin' => 'Ireland', 'user_id' => 1]);
Ingredient::create(['name' => 'St-Germain', 'ingredient_category_id' => $liqueurs->id, 'strength' => 20.0, 'description' => 'St-Germain is an elderflower liqueur It is made using the petals of Sambucus nigra from the Savoie region in France, and each bottle is numbered with the year the petals were collected. Petals are collected annually in the spring over a period of three to four weeks, and are often transported by bicycle to collection points to avoid damaging the petals and impacting the flavour.', 'color' => '#f8e888', 'origin' => 'France', 'user_id' => 1]);

$curacao = Ingredient::create(['name' => 'Orange Curaçao', 'ingredient_category_id' => $liqueurs->id, 'strength' => 20.0, 'description' => 'Liqueur flavored with the dried peel of the bitter orange laraha, a citrus fruit grown on the Dutch island of Curaçao. Curaçao is used by liqueur makers the world over as a generic name for orange-flavoured liqueurs.', 'color' => '#edaa53', 'origin' => 'Netherlands', 'user_id' => 1]);
Ingredient::create(['name' => 'Dry Curaçao', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Cognac Ferrand\'s innovative owner Alexandre Gabriel, followed an old recipe and modified it to create this curaçao. While Curaçao and sweet oranges are the main ingredients, vanilla, prunes and lemon peel are amongst the other botanicals called for in the old recipe.', 'origin' => 'Italy', 'user_id' => 1]);
Ingredient::create(['name' => 'Blue Curaçao', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 20.0, 'description' => 'Liqueur flavored with the dried peel of the bitter orange laraha, a citrus fruit grown on the Dutch island of Curaçao.', 'color' => '#0192fe', 'origin' => 'Netherlands', 'user_id' => 1]);
$curacao = Ingredient::create(['name' => 'Orange Curaçao', 'ingredient_category_id' => $liqueurs->id, 'strength' => 20.0, 'description' => 'Liqueur flavored with the dried peel of the bitter orange laraha, a citrus fruit grown on the Dutch island of Curaçao. Curaçao is used by liqueur makers overt the world as a generic name for orange-flavoured liqueurs.', 'color' => '#edaa53', 'origin' => 'Netherlands', 'user_id' => 1]);
Ingredient::create(['name' => 'Dry Curaçao', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'color' => '#ffc613', 'description' => 'While Curaçao and sweet oranges are the main ingredients, vanilla, prunes and lemon peel are amongst the other botanicals called for in the old recipe.', 'origin' => 'Italy', 'user_id' => 1]);
Ingredient::create(['name' => 'Blue Curaçao', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 20.0, 'description' => 'Curaçao with added blue dye.', 'color' => '#0192fe', 'origin' => 'Netherlands', 'user_id' => 1]);
Ingredient::create(['name' => 'Cointreau', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Orange-flavoured triple sec liqueur, it was originally called Curaçao Blanco Triple Sec. Usually more dry tasting than Orange Curaçao.', 'color' => '#ffffff', 'origin' => 'France', 'user_id' => 1]);
Ingredient::create(['name' => 'Triple Sec', 'parent_ingredient_id' => $curacao->id, 'ingredient_category_id' => $liqueurs->id, 'strength' => 40.0, 'description' => 'Triple sec is usually made from orange peels steeped in a spirit derived from sugar beet due to its neutral flavor.', 'color' => '#ffffff', 'origin' => 'France', 'user_id' => 1]);

// Juices
$lemonJuice = Ingredient::create(['name' => 'Lemon juice', 'ingredient_category_id' => $juices->id, 'strength' => 0.0, 'description' => 'Freshly squeezed lemon juice.', 'color' => '#f3efda', 'user_id' => 1]);
Expand Down Expand Up @@ -238,7 +238,7 @@ public function handle()
Ingredient::create(['name' => 'Dark Rum', 'parent_ingredient_id' => $rum->id, 'ingredient_category_id' => $spirits->id, 'strength' => 40.0, 'color' => '#ca5210', 'description' => 'Rum made from caramelized sugar or molasses.', 'origin' => 'Caribbean', 'user_id' => 1]);
Ingredient::create(['name' => 'Jamaican Rum', 'parent_ingredient_id' => $rum->id, 'ingredient_category_id' => $spirits->id, 'strength' => 40.0, 'color' => '#ca5210', 'description' => 'Rum made in Jamaica.', 'origin' => 'Jamaica', 'user_id' => 1]);
Ingredient::create(['name' => 'Rhum agricole', 'parent_ingredient_id' => $rum->id, 'ingredient_category_id' => $spirits->id, 'strength' => 50.0, 'color' => '#ffffff', 'description' => 'Rum distilled from freshly squeezed sugarcane juice rather than molasses.', 'origin' => 'Caribbean', 'user_id' => 1]);
Ingredient::create(['name' => 'Overproof Rum', 'parent_ingredient_id' => $rum->id, 'ingredient_category_id' => $spirits->id, 'strength' => 50.0, 'color' => '#ffffff', 'description' => 'Rum much higher than the standard 40% ABV (80 proof), with many as high as 75% (150 proof) to 80% (160 proof) available.', 'origin' => 'Caribbean', 'user_id' => 1]);
Ingredient::create(['name' => 'Overproof Rum', 'parent_ingredient_id' => $rum->id, 'ingredient_category_id' => $spirits->id, 'strength' => 50.0, 'color' => '#5d201a', 'description' => 'Rum much higher than the standard 40% ABV (80 proof), with many as high as 75% (150 proof) to 80% (160 proof) available.', 'origin' => 'Caribbean', 'user_id' => 1]);

Ingredient::create(['name' => 'Cachaça', 'ingredient_category_id' => $spirits->id, 'strength' => 40.0, 'color' => '#ffffff', 'description' => 'Distilled spirit made from fermented sugarcane juice.', 'origin' => 'Brazil', 'user_id' => 1]);
Ingredient::create(['name' => 'Pisco', 'ingredient_category_id' => $spirits->id, 'strength' => 40.0, 'color' => '#ffffff', 'description' => 'Made by distilling fermented grape juice into a high-proof spirit.', 'origin' => 'South America', 'user_id' => 1]);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function register(RegisterRequest $req)
$user->search_api_key = SearchActions::getPublicApiKey();
$user->save();

return new UserResource(
return (new UserResource(
$user->load('favorites', 'shelfIngredients', 'shoppingLists')
);
))->response()->setStatusCode(200);
}
}
9 changes: 3 additions & 6 deletions app/Http/Controllers/CocktailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function store(CocktailService $cocktailService, CocktailRequest $request
/**
* Update a single cocktail by id
*/
public function update(CocktailService $cocktailService, CocktailRequest $request, int $id): JsonResponse
public function update(CocktailService $cocktailService, CocktailRequest $request, int $id)
{
try {
$cocktail = $cocktailService->updateCocktail(
Expand All @@ -118,10 +118,7 @@ public function update(CocktailService $cocktailService, CocktailRequest $reques

$cocktail->load('ingredients.ingredient', 'images', 'tags', 'glass', 'ingredients.substitutes');

return (new CocktailResource($cocktail))
->response()
->setStatusCode(201)
->header('Location', route('cocktails.show', $cocktail->id));
return new CocktailResource($cocktail);
}

/**
Expand All @@ -131,7 +128,7 @@ public function delete(int $id)
{
Cocktail::findOrFail($id)->delete();

return new SuccessActionResource((object) ['id' => $id]);
return response(null, 204);
}

/**
Expand Down
39 changes: 36 additions & 3 deletions app/Http/Controllers/GlassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,56 @@

namespace Kami\Cocktail\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Kami\Cocktail\Models\Glass;
use Illuminate\Http\JsonResponse;
use Kami\Cocktail\Http\Requests\GlassRequest;
use Kami\Cocktail\Http\Resources\GlassResource;
use Illuminate\Http\Resources\Json\JsonResource;

class GlassController extends Controller
{
public function index()
public function index(): JsonResource
{
$glasses = Glass::orderBy('name')->get();

return GlassResource::collection($glasses);
}

public function show(int $id)
public function show(int $id): JsonResource
{
$glass = Glass::findOrFail($id);

return new GlassResource($glass);
}

public function store(GlassRequest $request): JsonResponse
{
$glass = new Glass();
$glass->name = $request->post('name');
$glass->description = $request->post('description');
$glass->save();

return (new GlassResource($glass))
->response()
->setStatusCode(201)
->header('Location', route('glasses.show', $glass->id));
}

public function update(int $id, GlassRequest $request): JsonResource
{
$glass = Glass::findOrFail($id);
$glass->name = $request->post('name');
$glass->description = $request->post('description');
$glass->save();

return new GlassResource($glass);
}

public function delete(int $id): Response
{
Glass::findOrFail($id)->delete();

return response(null, 204);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public function delete(int $id)
{
Image::findOrFail($id)->delete();

return new SuccessActionResource((object) ['id' => $id]);
return response(null, 204);
}
}
11 changes: 5 additions & 6 deletions app/Http/Controllers/IngredientCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public function store(IngredientCategoryRequest $request)

return (new IngredientCategoryResource($category))
->response()
->setStatusCode(201);
->setStatusCode(201)
->header('Location', route('ingredient-categories.show', $category->id));
}

public function update(IngredientCategoryRequest $request, int $id)
Expand All @@ -43,15 +44,13 @@ public function update(IngredientCategoryRequest $request, int $id)
$category->description = $request->post('description');
$category->save();

return (new IngredientCategoryResource($category))
->response()
->setStatusCode(201);
return new IngredientCategoryResource($category);
}

public function delete(int $id)
{
IngredientCategory::findOrFail($id)->delete();
return new SuccessActionResource((object) ['id' => $id]);

return response(null, 204);
}
}
7 changes: 5 additions & 2 deletions app/Http/Controllers/IngredientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function store(IngredientService $ingredientService, IngredientRequest $r
$request->post('images', [])
);

return new IngredientResource($ingredient);
return (new IngredientResource($ingredient))
->response()
->setStatusCode(201)
->header('Location', route('ingredients.show', $ingredient->id));
}

public function update(IngredientService $ingredientService, IngredientRequest $request, int $id)
Expand All @@ -80,6 +83,6 @@ public function delete(int $id)
{
Ingredient::findOrFail($id)->delete();

return new SuccessActionResource((object) ['id' => $id]);
return response(null, 204);
}
}
6 changes: 2 additions & 4 deletions app/Http/Controllers/ShelfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Illuminate\Http\Request;
use Kami\Cocktail\Models\UserIngredient;
use Kami\Cocktail\Models\UserShoppingList;
use Kami\Cocktail\Http\Resources\ErrorResource;
use Kami\Cocktail\Http\Resources\SuccessActionResource;
use Kami\Cocktail\Http\Resources\UserIngredientResource;
use Kami\Cocktail\Http\Requests\UserIngredientBatchRequest;

Expand Down Expand Up @@ -64,9 +62,9 @@ public function delete(Request $request, int $ingredientId)
->where('ingredient_id', $ingredientId)
->delete();
} catch (Throwable $e) {
return new ErrorResource($e);
abort(500, $e->getMessage());
}

return new SuccessActionResource((object) ['id' => $ingredientId]);
return response(null, 204);
}
}
Loading

0 comments on commit bebb9bb

Please sign in to comment.