Hey! No problem, its good that you're reaching out for help.
Create a model named Location which has a table locations where you can add the different locations like bag, kitchen, etc.
SCHEMA
For the columns in the product database schema use type integer instead of string because you want to use the id as value which is not a string but an integer(number). You could also add _id to the from_location and to_location column names to follow the conventions.
$table->integer('from_location_id');
$table->integer('to_location_id');
When you now want to add a location to a product you can use the id of that location from the locations table and set it as value in the from_location_id or to_location_id columns
RELATIONS
If this is al set, you can add relations so you can easily get the to and from locations of a product.
In the Location Model use these relations to get all the products for the from or to location.
public function productsFrom()
{
return $this->hasMany(Product::class, 'from_location_id');
}
public function productsTo()
{
return $this->hasMany(Product::class, 'to_location_id');
}
In the Product model use these relations to get the from or to location of a product.
public function fromLocation()
{
return $this->belongsTo(Location::class, 'from_location_id');
}
public function toLocation()
{
return $this->belongsTo(Location::class, 'to_location_id');
}
Also check this episode from the Laravel in 30 days serie. It explains the basics about the relations above. https://laracasts.com/series/30-days-to-learn-laravel-11/episodes/11
This are the links from the Laravel docs about these relations https://laravel.com/docs/11.x/eloquent-relationships#one-to-many https://laravel.com/docs/11.x/eloquent-relationships#one-to-many-inverse