| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2022/8/3
- * Time: 16:53
- */
- namespace business\common\notice;
- use business\common\models\MessageNotice;
- use Illuminate\Container\Container;
- use Illuminate\Support\Str;
- class BusinessNoticeManager extends Container
- {
- public function __construct()
- {
- $this->bind('MessageNotice',function ($messageNotice,$attributes = []) {
- return new MessageNotice($attributes);
- });
- $this->singleton('ProductCollection',function ($messageNotice) {
- return new NoticeProductCollection();
- });
- $this->setShopProduct();
- }
- private function setShopProduct()
- {
- $this->make('ProductCollection')->bind('shop', function ($manager, $params) {
- return new BusinessShopNotice();
- });
- }
- public function getAllProduct()
- {
- $allProduct = collect([]);
- $productContainer = app('BusinessMsgNotice')->make('ProductCollection')->getBindings();
- foreach ($productContainer as $key => $value) {
- $allProduct->push($this->getProduct($key));
- }
- return $allProduct->filter()->values();
- }
- /**
- * @param $code
- * @return BusinessMessageNoticeBase|bool
- * @throws \Illuminate\Contracts\Container\BindingResolutionException
- */
- public function getProduct($code)
- {
- if (app('BusinessMsgNotice')->make('ProductCollection')->bound($code)) {
- return app('BusinessMsgNotice')->make('ProductCollection')->make($code);
- }
- return false;
- }
- }
|