1818use Rapidez \Core \Models \Traits \HasAlternatesThroughRewrites ;
1919use Rapidez \Core \Models \Traits \HasCustomAttributes ;
2020use Rapidez \Core \Models \Traits \Product \BackwardsCompatibleAccessors ;
21+ use Rapidez \Core \Models \Traits \Product \HasProductLinks ;
2122use Rapidez \Core \Models \Traits \Product \HasSuperAttributes ;
2223use Rapidez \Core \Models \Traits \Product \Searchable ;
2324use Rapidez \Core \Models \Traits \UsesCallbackRelations ;
@@ -27,6 +28,7 @@ class Product extends Model
2728 use BackwardsCompatibleAccessors;
2829 use HasAlternatesThroughRewrites;
2930 use HasCustomAttributes;
31+ use HasProductLinks;
3032 use HasSuperAttributes;
3133 use Searchable;
3234 use UsesCallbackRelations;
@@ -152,40 +154,6 @@ protected function grouped(): Attribute
152154 return Attribute::get (fn () => $ this ->children );
153155 }
154156
155- public function productLinks (): HasMany
156- {
157- return $ this ->hasMany (
158- config ('rapidez.models.product_link ' , ProductLink::class),
159- 'product_id ' , 'entity_id ' ,
160- );
161- }
162-
163- public function productLinkParents (): HasMany
164- {
165- return $ this ->hasMany (
166- config ('rapidez.models.product_link ' , ProductLink::class),
167- 'linked_product_id ' , 'entity_id ' ,
168- );
169- }
170-
171- public function getLinkedProducts (string $ type ): Collection
172- {
173- return $ this ->productLinks ()
174- ->with ('linkedProduct ' )
175- ->where ('code ' , $ type )
176- ->get ()
177- ->pluck ('linkedProduct ' );
178- }
179-
180- public function getLinkedParents (string $ type ): Collection
181- {
182- return $ this ->productLinkParents ()
183- ->with ('linkedParent ' )
184- ->where ('code ' , $ type )
185- ->get ()
186- ->pluck ('linkedParent ' );
187- }
188-
189157 public function categoryProducts (): HasMany
190158 {
191159 return $ this
0 commit comments