Setup the inner pages
make newsletter section functional
create a Foldagram form that a user can access from any page
modify workbench configuration file
run 'php artisan workbench acme/cart --resources'
register CartService provider then run 'php artisan dump-autoload'
access workbench Cart class like any other class by using Facades classes
redefine Cart class in Cart package to handle the session and initialize necessary parts
sett initial items, such as quantity, price, and row ID, from array. Row ID is generated by the md5 method for creating a unique row for our cart contents, so later we can use this to update our record or delete it from our container. After updating individual items, we are merging the array into our container.
validate method first check if the array is empty; if it is throw an error. Next, check if all our indexes are present in our item array. And lastly check qty and price for the numeric values.
Initially merge our total items and cart total with our container. Then we'll loop through each item and update our cart total and total items in the cart. And finally we will use the session library's put method to put our data into the session, so our data is preserved between requests.
If someone changes our Foldagram quantity, we need to update our cart to make sure our price is updated. We also need track if somebody updates the quantity as 0; this means we need to remove that Foldagram from our Cart.
To delete an item from cart, all we need is the rowid of that item. If rowid is passed, we just need to call our update method with the item array as rowid and the quantity as 0. Our update method will handle this and remove it from our cart, as well as update the session as it already has a mechanism for that.
viewing the cart total
Delete all items from the cart. First, we override our container with empty values and then remove it from our current session.
As we already have the total_items key, which updates the total items in the cart when an item is added, edited, or deleted; we don't need to count it, we cangrab it from our cart.
We need to rewrite our service provider, as we are passing a dependency of our session. We need to pass it via service provider's register method. We resolve our session array by injecting it into Cart class via ->app['session']. So Laravel will make sure that whenever a new instance of Cart class is created, an instance of the session class will be injected into our Cart class.
php artisan migrate:make create_foldagrams_table && php artisan migrate:make create_recipients_table
modify generated migrations and run 'php artisan migrate'
create foldagram and recipient model