Skip to content

Instantly share code, notes, and snippets.

@insign
Created January 28, 2017 22:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save insign/e1959af73e6c4477d9f882ce836b7c0c to your computer and use it in GitHub Desktop.
<?php
// This will create a product, apply a discount since it is a new
// product, and send a notification via email
public function store()
{
// Create product from request
$product = Product::create($request->all());
// Get the discount to be applied
$discount = Discount::byType('newProduct');
// Apply discount for the created product
$discount->applyDiscountForProduct($product);
$users = User::all();
// Notify users for the newly created product
foreach ($users as $user) {
// Notify users via email
$notification = Notification::via('email');
$notification->notifyUser($user);
}
return 'Success';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment