This commit is contained in:
2024-10-12 16:17:16 +02:00
commit 1bdefcff66
65 changed files with 10816 additions and 0 deletions

18
app/Models/Ingredient.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Ingredient extends Model
{
use HasFactory;
protected $fillable = ['product_id', 'name'];
public function product()
{
return $this->belongsTo(Product::class);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class NutritionFact extends Model
{
use HasFactory;
protected $fillable = ['product_id', 'nutrient', 'amount', 'unit'];
public function product()
{
return $this->belongsTo(Product::class);
}
}

32
app/Models/Product.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasFactory;
protected $guarded = ['id'];
protected $casts = [
'no_nutriments' => 'boolean',
'additives_n' => 'integer',
'ingredients_from_palm_oil_n' => 'integer',
'ingredients_that_may_be_from_palm_oil_n' => 'integer',
'nutriscore_score' => 'integer',
'nova_group' => 'integer',
];
public function ingredients()
{
return $this->hasMany(Ingredient::class);
}
public function nutritionFacts()
{
return $this->hasMany(NutritionFact::class);
}
}

48
app/Models/User.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}