|
@@ -10,8 +10,6 @@ use Hashids;
|
|
|
|
|
|
class CrmBooklistController extends Controller
|
|
|
{
|
|
|
- private $channel_id;
|
|
|
-
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
$month = date('n');
|
|
@@ -20,8 +18,6 @@ class CrmBooklistController extends Controller
|
|
|
|
|
|
public function bookshow(Request $request)
|
|
|
{
|
|
|
- $user = app()->make('user');
|
|
|
- $this->channel_id = $user->channel_id;
|
|
|
$booklists = (new CrmBookAutoRecommendService)->getRecommendBooksFromRedis();
|
|
|
$book_models = collect($booklists)->groupBy('category_id')
|
|
|
->map(function ($item, $key) {
|
|
@@ -33,7 +29,7 @@ class CrmBooklistController extends Controller
|
|
|
$item['link'] = sprintf(
|
|
|
'%s://site%s.%s.com/detail?id=%s',
|
|
|
env('PROTOCOL'),
|
|
|
- encodeDistributionChannelId($this->channel_id),
|
|
|
+ encodeDistributionChannelId($this->getUserColumnValue('channel_id')),
|
|
|
env('CUSTOM_HOST'),
|
|
|
Hashids::encode($item['bid'])
|
|
|
);
|
|
@@ -46,8 +42,6 @@ class CrmBooklistController extends Controller
|
|
|
|
|
|
public function booklist(Request $request)
|
|
|
{
|
|
|
- $user = app()->make('user');
|
|
|
- $this->channel_id = $user->channel_id;
|
|
|
$month = date('n');
|
|
|
$category_id = $request->get('category_id', 0);
|
|
|
$books = [];
|
|
@@ -57,13 +51,21 @@ class CrmBooklistController extends Controller
|
|
|
$item['link'] = sprintf(
|
|
|
'%s://site%s.%s.com/detail?id=%s',
|
|
|
env('PROTOCOL'),
|
|
|
- encodeDistributionChannelId($this->channel_id),
|
|
|
+ encodeDistributionChannelId($this->getUserColumnValue('channel_id')),
|
|
|
env('CUSTOM_HOST'),
|
|
|
Hashids::encode($item['bid'])
|
|
|
);
|
|
|
return $item;
|
|
|
})->all();
|
|
|
}
|
|
|
- return view('crm.booklist',compact('books', 'month'));#->with(compact('books', 'month'));
|
|
|
+ return view('crm.booklist', compact('books', 'month')); #->with(compact('books', 'month'));
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getUserColumnValue(string $column)
|
|
|
+ {
|
|
|
+ $user = app()->make('user');
|
|
|
+ if ($user) {
|
|
|
+ return $user->$column;
|
|
|
+ }
|
|
|
}
|
|
|
}
|