|
@@ -6,6 +6,7 @@ use App\Models\DistProductCategory as Model;
|
|
|
|
|
|
use App\Models\DistProductParameter;
|
|
|
use Dcat\Admin\Repositories\EloquentRepository;
|
|
|
+use Illuminate\Support\Facades\Session;
|
|
|
|
|
|
class DistProductCategory extends EloquentRepository
|
|
|
{
|
|
@@ -68,24 +69,26 @@ class DistProductCategory extends EloquentRepository
|
|
|
*/
|
|
|
public function get(Grid\Model|\Dcat\Admin\Grid\Model $model)
|
|
|
{
|
|
|
+
|
|
|
+ $distributor=Session::get('distributor');
|
|
|
|
|
|
+
|
|
|
$obj = $this->model();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- $obj->where('dist_user_id',0);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ if ($distributor) {
|
|
|
+ $obj = $obj->where('dist_id', $distributor->id);
|
|
|
+ }
|
|
|
+
|
|
|
$tree = $obj->get();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
$data=buildTree($tree->toArray());
|
|
|
-
|
|
|
+
|
|
|
$data=flattenTree($data);
|
|
|
|
|
|
return $model->makePaginator(
|
|
|
- 1,
|
|
|
+ count($data),
|
|
|
$data
|
|
|
);
|
|
|
}
|