Use MicroKernelTrait to bootstrap application. Rewrote routes, controllers and structure of application a bit. Including use of twig.

This commit is contained in:
Krzysztof Płaczek
2024-10-19 16:01:54 +02:00
parent 3d47726a81
commit 5ee1bba812
16 changed files with 1593 additions and 73 deletions

View File

@@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
* @property string $variantCode
* @property string $modelCode
* @property string $url
* @property boolean $starred
* @property int $starred
*/
class Product extends Model
{
@@ -30,10 +30,16 @@ class Product extends Model
return $this->hasMany(Price::class);
}
public function isStarred(): bool
{
return (bool) $this->starred;
}
public function currentPrice(): HasOne
{
return $this->hasOne(Price::class)->latestOfMany('created_at');
}
public function stock(): HasMany
{
return $this->hasMany(Stock::class);
@@ -42,6 +48,7 @@ class Product extends Model
public function toggleStarred(): self
{
$this->starred = !$this->starred;
return $this;
}