Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This update support laravel 5.4 and 5.5 #62

Open
wants to merge 15 commits into
base: v0.2
Choose a base branch
from
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
LARAVEL SHOP (Laravel 5.1 Package)
LARAVEL SHOP (Laravel 5.5 Package)
--------------------------------

[![Latest Stable Version](https://poser.pugx.org/amsgames/laravel-shop/v/stable)](https://packagist.org/packages/amsgames/laravel-shop)
[![Total Downloads](https://poser.pugx.org/amsgames/laravel-shop/downloads)](https://packagist.org/packages/amsgames/laravel-shop)
[![Latest Unstable Version](https://poser.pugx.org/amsgames/laravel-shop/v/unstable)](https://packagist.org/packages/amsgames/laravel-shop)
[![License](https://poser.pugx.org/amsgames/laravel-shop/license)](https://packagist.org/packages/amsgames/laravel-shop)

Laravel Shop is flexible way to add shop functionality to **Laravel 5.1**. Aimed to be the e-commerce solution for artisans.
Laravel Shop is flexible way to add shop functionality to **Laravel 5.4**. Aimed to be the e-commerce solution for artisans.

Laravel shop adds shopping cart, orders and payments to your new or existing project; letting you transform any model into a shoppable item.

Expand Down Expand Up @@ -85,7 +85,7 @@ On the horizon:
With composer

```bash
composer require amsgames/laravel-shop
composer require baklysystems/laravel-shop
```

Or add
Expand All @@ -96,6 +96,18 @@ Or add

to your composer.json. Then run `composer install` or `composer update`.

Then in your `config/auth.php` add `'table' => 'users',` to provdiers.users

```php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users',
],

```

Then in your `config/app.php` add

```php
Expand Down Expand Up @@ -879,7 +891,7 @@ $transaction = $order->placeTransaction(
```php
$completed = $order->isCompleted
// Checks if order is in a specific status.
$success = $order->is('completed');
$success = $order->statusCodeIs('completed');

// Quering
// Get orders from specific user ID.
Expand Down Expand Up @@ -926,7 +938,7 @@ Then use it like:
```php
$myStatusCode = 'my_status';

if ($order->is($myStatusCode)) {
if ($order->statusCodeIs($myStatusCode)) {
echo 'My custom status work!';
}
```
Expand Down Expand Up @@ -1194,4 +1206,4 @@ Laravel Shop is free software distributed under the terms of the MIT license.
This package's architecture and design was inpired by the **Zizaco/entrust** package, we'll like to thank their contributors for their awesome woek.

## Change Log
* [v0.2.8](https://github.com/amsgames/laravel-shop/releases/tag/v0.2.8)
* [v0.2.8](https://github.com/amsgames/laravel-shop/releases/tag/v0.2.8)
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amsgames/laravel-shop",
"description": "Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.",
"name": "baklysystems/laravel-shop",
"description": "This is just an update for amsgames/laravel-shop to support 5.4 as they don't update it anymore. Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.",
"license": "MIT",
"keywords": ["shop","laravel","cart","orders","transactions","paypal","e-commerce","shopping cart","ecommerce","shopping"],
"authors": [
Expand All @@ -12,6 +12,11 @@
"name": "Alejandro Mostajo",
"email": "amostajo@gmail.com"
}
,
{
"name": "Mostafa Elbakly",
"email": "elbakly@gmail.com"
}
],
"require": {
"php": ">=5.5.9",
Expand All @@ -28,4 +33,4 @@
}
},
"minimum-stability": "dev"
}
}
16 changes: 13 additions & 3 deletions src/Commands/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ public function fire()

}
}

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->fire();
}

/**
* Create the migration.
Expand All @@ -127,8 +137,8 @@ protected function createMigration($data)
{
$migrationFile = base_path('/database/migrations') . '/' . date('Y_m_d_His') . '_shop_setup_tables.php';

$usersTable = Config::get('auth.table');
$userModel = Config::get('auth.model');
$usersTable = Config::get('auth.providers.users.table');
$userModel = Config::get('auth.providers.users.model');
$userKeyName = (new $userModel())->getKeyName();

$data = array_merge($data, compact('usersTable', 'userKeyName'));
Expand Down Expand Up @@ -165,4 +175,4 @@ protected function createSeeder($data)

return false;
}
}
}
4 changes: 2 additions & 2 deletions src/Contracts/ShopOrderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function getDisplayTotalAttribute();
*
* @return bool
*/
public function is($statusCode);
public function statusCodeIs($statusCode);

/**
* Creates the order's transaction.
Expand Down Expand Up @@ -174,4 +174,4 @@ public function scopeWhereSKU($query, $sku);
*/
public function scopeWhereStatusIn($query, array $statusCodes);

}
}
3 changes: 1 addition & 2 deletions src/LaravelShopProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ class LaravelShopProvider extends ServiceProvider
*
* @return void
*/
public function boot(Router $router)
public function boot()
{
parent::boot($router);

// Publish config files
$this->publishes([
Expand Down
4 changes: 2 additions & 2 deletions src/Models/ShopItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(array $attributes = [])
*/
public function user()
{
return $this->belongsTo(Config::get('auth.model'), 'user_id');
return $this->belongsTo(Config::get('auth.providers.users.model'), 'user_id');
}

/**
Expand All @@ -91,4 +91,4 @@ public function order()
return $this->belongsTo(Config::get('shop.order'), 'order_id');
}

}
}
7 changes: 4 additions & 3 deletions src/Traits/ShopCartTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function boot()
parent::boot();

static::deleting(function($user) {
if (!method_exists(Config::get('auth.model'), 'bootSoftDeletingTrait')) {
if (!method_exists(Config::get('auth.providers.users.model'), 'bootSoftDeletingTrait')) {
$user->items()->sync([]);
}

Expand All @@ -53,7 +53,7 @@ public static function boot()
*/
public function user()
{
return $this->belongsTo(Config::get('auth.model'), 'user_id');
return $this->belongsTo(Config::get('auth.providers.users.model'), 'user_id');
}

/**
Expand Down Expand Up @@ -139,6 +139,7 @@ public function remove($item, $quantity = 0)
if (!empty($quantity)) {
$cartItem->quantity -= $quantity;
$cartItem->save();
$this->resetCalculations();
if ($cartItem->quantity > 0) return true;
}
$cartItem->delete();
Expand Down Expand Up @@ -304,4 +305,4 @@ private function getItem($sku)
->first();
}

}
}
8 changes: 4 additions & 4 deletions src/Traits/ShopOrderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function boot()
parent::boot();

static::deleting(function($user) {
if (!method_exists(Config::get('auth.model'), 'bootSoftDeletingTrait')) {
if (!method_exists(Config::get('auth.providers.users.model'), 'bootSoftDeletingTrait')) {
$user->items()->sync([]);
}

Expand All @@ -44,7 +44,7 @@ public static function boot()
*/
public function user()
{
return $this->belongsTo(Config::get('auth.model'), 'user_id');
return $this->belongsTo(Config::get('auth.providers.users.model'), 'user_id');
}

/**
Expand Down Expand Up @@ -158,7 +158,7 @@ public function scopeFindByUser($query, $userId, $statusCode = null) {
*
* @return bool
*/
public function is($statusCode)
public function statusCodeIs($statusCode)
{
return $this->attributes['statusCode'] == $statusCode;
}
Expand Down Expand Up @@ -258,4 +258,4 @@ private function getItem($sku)
->where('order_id', $this->attributes['id'])
->first();
}
}
}