The fluent laravel marketplace
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
the marketplace CheatSheet will be availble soon
Create simple products, and complex ones using variation system by attaching the product to a specific type.
Generate , Validate , and purchase them while checkout easily.
After creating your new Laravel application you can include the marketplace package with the following command:
composer require sectheater/marketplace:dev-master
Next make sure to create a new database and add your database credentials to your .env file:
DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
You will also want to update your website URL inside of the
APP_URLvariable inside the .env file:
php artisan sectheater-market:install
Notice : You may need to run the autoload composer command to reload the changes.
composer dump-autoload -o
Another Notice : Don't forget to delete the default users table migration, as marketplace ships with a default one as well.
Product::generate([ 'user_id' => auth()->id(), 'name' => 'laptop', 'description' => 'Fancy laptop', 'price' => 15000, 'category' => 'electronics', 'type' => ['name' => 'MacBook Pro', 'stock' => 20], 'details' => ['color' => 'Silver', 'dummy-feature' => 'dummy-text'] );
Product::fetchByVariations(['locations' => 'U.K', 'variations' => ['size' => 'XL', 'color' => 'red'], 'categories' => 'clothes']);
Out of the blue, you may use a couple of methods to retrieve the total/subtotal ```php Cart::subtotal(); Cart::total(); // returns total after applying tax. Cart::total($coupons); // Collection of coupons passed, returns total after applying tax and coupons. Cart::subtotalAfterCoupon($coupons);
Suprisingly every single method you can use for a cart, you can use for a wishlist ( since we can consider it as a virtual cart )
4.4 get Cart item .
Cart::item(1); // get the item with id of 1
Cart::item(1, ['color' => 'blue', 'size' => 'L']); // get the item with the id of 1 and should have these attributes.
Cart::item(null, ['color' => 'blue','size' => 'L']); // get the current authenticated user's cart which has these attributes assuming that these attributes identical to the database record.
Cart::item(null, ['color' => 'blue','size' => 'L'] , 'or'); // get the current authenticated user's cart which has any of these attributes.
Coupon::generate([ 'user_id' => auth()->id(), 'active' => true, 'percentage' => 10.5, 'expires_at' => Carbon::now()->addWeeks(3)->format('Y-m-d H:i:s') ]);
$coupon = Coupon::first(); // valid one Coupon::validate($coupon); // returns true
$coupon = Coupon::first(); Coupon::deactivate($coupon->id);
$coupon = Coupon::first(); Coupon::purchase($coupon); // Purchase the coupon for the current authenticated user. Coupon::purchase($coupon, $anotherUser); // Purchase the coupon for the passed user.
php Coupon::purchased(); // returns the only valid purchased coupons.##### 4.8 Apply Specific Coupons.
Coupon::appliedCoupons($coupons); // returns a query builder.
For more, you can view the docs.