vendredi 10 juillet 2020

Laravel how to define relationship based on two models or columns?

I have the following:

//users table
id
name
email
remeber_token
role_id
//roles table
id
name
//products table
id
name
//product_prices 
role_id
product_id
price

The price of the product will vary depending on the user role, how to define the correct relationship so in blade I can do something like:

$product->price

and that will return the correct price depending on the user and the product?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3fjUWSH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire