*/ use HasFactory; /** * @return ProductFactory */ protected static function newFactory(): ProductFactory { return ProductFactory::new(); } /** * @param Builder $q */ public function scopeSearch(Builder $q, string $s): void { $s = "%{$s}%"; $q->where(fn(Builder $q) => ( $q->orWhere('name', 'like', $s) ->orWhere('description', 'like', $s) )); } /** * @return BelongsTo */ public function category(): BelongsTo { return $this->belongsTo(Category::class); } }