Refactor product relations to use new category_product and channel_product tables
- Updated queries and relationships in various controllers and models to replace `product_has_relations` with `category_product` and `channel_product`. - Adjusted methods in `ProductFilterer`, `FilterParamsController`, and `FilterController` to reflect the new database structure. - Modified seeder to insert data into the new `channel_product` table. - Updated tests to ensure compatibility with the new product relation structure.
This commit is contained in:
@@ -33,9 +33,8 @@ class ProductEntrepreneurFilter extends Filter
|
||||
*/
|
||||
public function apply(NovaRequest $request, $query, $value)
|
||||
{
|
||||
$vendorProducts = DB::table('product_has_relations')
|
||||
->where('productable_type', 'channel')
|
||||
->where('productable_id', $value)
|
||||
$vendorProducts = DB::table('channel_product')
|
||||
->where('channel_id', $value)
|
||||
->pluck('product_id');
|
||||
|
||||
$query->whereIntegerInRaw('id', $vendorProducts);
|
||||
|
||||
@@ -123,9 +123,8 @@ class Product extends Resource
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->hasRole('vendor')) {
|
||||
$vendorProducts = DB::table('product_has_relations')
|
||||
->where('productable_type', 'channel')
|
||||
->where('productable_id', $user->channel()->id)
|
||||
$vendorProducts = DB::table('channel_product')
|
||||
->where('channel_id', $user->channel()->id)
|
||||
->pluck('product_id');
|
||||
|
||||
$query->whereIntegerInRaw('id', $vendorProducts);
|
||||
|
||||
Reference in New Issue
Block a user