Swell

Modèles

Les modèles dans Swell, adaptez-les à votre projet.

Les modèles de données

Swell propose une collection de modèles prêts à l’emploi, conçus pour couvrir les besoins courants d’un projet e-commerce moderne.

Ces modèles servent de base solide, mais restent entièrement personnalisables afin de s’adapter à la structure et aux spécificités de votre application.

Vous pouvez ainsi les modifier ou en créer de nouveaux selon les exigences de votre domaine métier, tout en profitant d’une intégration fluide avec l’écosystème Swell.

Adapter un modèle

Les modèles Swell sont basiquement situés dans le dossier app/Models, à l’exception des fonctionnalités optionnelles dont les modèles sont placés dans app/Modules/Feature/Models.

Ils sont associés à leurs fichiers de migration respectifs dans database/migrations ou Modules/Feature/database/migrations, permettant de définir la structure des tables correspondantes.

Swell n’impose aucune logique métier. Les modèles proposés servent de socle initial, à adapter librement. Pour toute modification de structure ou comportement, référez-vous à la documentation officielle de Laravel.

Structure des modèles

Brand

ChampType
namestring
slugstring unique
logo_urlstring nullable
HasMany(Product).

Category

ChampType
namestring
slugstring unique
descriptiontext nullable
statusboolean defaut:true
parent_idnullable nullOnDelete
BelongsTo(Category).
HasMany(Category).
BelongsToMany(Product).

Product

ChampType
namestring
slugstring unique
skustring unique
descriptiontext
short_descriptionstring max:500
pricedecimal:10,2
discount_pricedecimal:10,2
cost_pricedecimal:10,2
stockunsignedInteger default:0
reorder_levelunsignedInteger default:10
statusboolean default:true
meta_titlestring nullable
meta_descriptionstring max:255 nullable
meta_keywordsstring max:255 nullable
brand_idinteger restrictOnDelete
product_group_idinteger nullable nullOnDelete
BelongsToMany(Category).
BelongsTo(Brand).
HasMany(ProductImage).
BelongsTo(ProductGroup).
BelongsToMany(Wishlist).
HasMany(Comment).

ProductGroup

ChampType
namestring
slugstring unique
HasMany(Product).
ProductGroup permet d’associer plusieurs produits entre eux au sein d’un même groupe.

ProductImage

ChampType
image_urlstring
alt_textstring nullable
is_featuredboolean default:false
orderunsignedInteger
BelongsTo(Product).

ProductComment

ChampType
titlestring
commenttext nullable
ratingunsignedTinyInteger default:0
user_idinteger cascadeOnDelete
product_idinteger cascadeOnDelete
BelongsTo(User).
BelongsTo(Product).

Cart

ChampType
session_idstring nullable
user_idinteger nullable cascadeOnDelete
BelongsTo(User).
HasMany(CartItem).

CartItem

ChampType
cart_idinteger cascadeOnDelete
product_idinteger cascadeOnDelete
quantityunsignedInteger default:1
BelongsTo(Product).
BelongsTo(Cart).

Wishlist

ChampType
user_idinteger cascadeOnDelete
BelongsTo(User).
BelongsToMany(Product).

Order

ChampType
order_numberstring unique
stripe_checkout_session_idstring
amount_discountunsignedInteger
amount_subtotalunsignedInteger
amount_totalunsignedInteger
billing_addressjson
shipping_addressjson
user_idinteger cascadeOnDelete
HasMany(OrderItem).
BelongsTo(User).

OrderItem

ChampType
namestring
descriptiontext
priceunsignedInteger
quantityunsignedInteger
amount_discountunsignedInteger
amount_totalunsignedInteger
order_idinteger
product_idinteger
BelongsTo(Order).
BelongsTo(Product).
ChampType
messagestring
is_activeboolean
orderunsignedInteger default:0