Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'multiple-prices' into develop
- Loading branch information
Showing
39 changed files
with
1,930 additions
and
990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace OFFLINE\Mall\Classes\Seeders; | ||
|
||
use October\Rain\Database\Updates\Seeder; | ||
use OFFLINE\Mall\Models\CustomerGroup; | ||
|
||
class CustomerGroupTableSeeder extends Seeder | ||
{ | ||
public function run() | ||
{ | ||
if (app()->environment() === 'testing') { | ||
$group = new CustomerGroup(); | ||
$group->name = 'Gold Partners'; | ||
$group->code = 'gold'; | ||
$group->save(); | ||
|
||
$group = new CustomerGroup(); | ||
$group->name = 'Silver Partners'; | ||
$group->code = 'silver'; | ||
$group->save(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace OFFLINE\Mall\Classes\Traits; | ||
|
||
use RainLab\User\Facades\Auth; | ||
|
||
trait UserSpecificPrice | ||
{ | ||
public function getUserSpecificPrice() | ||
{ | ||
if ( ! $this->hasUserSpecificPrice()) { | ||
return parent::getAttribute('price'); | ||
} | ||
|
||
$group = optional(Auth::getUser())->offline_mall_customer_group_id; | ||
$price = $this->customer_group_prices->where('customer_group_id', $group)->first()->getOriginal('price'); | ||
|
||
return $price ? json_decode($price, true) : parent::getAttribute('price'); | ||
} | ||
|
||
protected function hasUserSpecificPrice(): bool | ||
{ | ||
return ! app()->runningInBackend() | ||
&& app()->has('user.auth') | ||
&& optional(Auth::getUser())->offline_mall_customer_group_id !== null | ||
&& $this->customer_group_prices->count() > 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php namespace OFFLINE\Mall\Controllers; | ||
|
||
use Backend\Behaviors\RelationController; | ||
use Backend\Classes\Controller; | ||
use BackendMenu; | ||
use Backend\Behaviors\ListController; | ||
use Backend\Behaviors\FormController; | ||
use Backend\Behaviors\ReorderController; | ||
|
||
class CustomerGroups extends Controller | ||
{ | ||
public $implement = [ | ||
ListController::class, | ||
FormController::class, | ||
ReorderController::class, | ||
RelationController::class, | ||
]; | ||
|
||
public $listConfig = 'config_list.yaml'; | ||
public $formConfig = 'config_form.yaml'; | ||
public $reorderConfig = 'config_reorder.yaml'; | ||
public $relationConfig = 'config_relation.yaml'; | ||
|
||
public $requiredPermissions = [ | ||
'offline.mall.manage_customer_groups', | ||
]; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
BackendMenu::setContext('RainLab.User', 'user', 'customer_groups'); | ||
} | ||
} |
Oops, something went wrong.