Added a way to starr a product, so it floats on top of the list of products

This commit is contained in:
Krzysztof Płaczek
2024-05-19 11:43:56 +02:00
parent 584bdcdf89
commit a204439a27
4 changed files with 21 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property string $variantCode
* @property string $modelCode
* @property string $url
* @property boolean $starred
*/
class Product extends Model
{
@@ -29,6 +30,12 @@ class Product extends Model
return $this->hasMany(Price::class);
}
public function toggleStarred(): self
{
$this->starred = !$this->starred;
return $this;
}
protected function categories(): Attribute
{
return Attribute::make(