Imrpoving Item, Product and Users

This commit is contained in:
2018-09-11 20:48:09 -03:00
parent 4b3c2089f5
commit 0f15e60c95
17 changed files with 155 additions and 59 deletions

View File

@@ -6,6 +6,23 @@ use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
protected $fillable = ['adminID', 'name'];
//
protected $fillable = ['admin_id', 'name'];
public function items()
{
return $this->hasMany(Item::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
//Ótima forma de adicionar um item por dentro do produto. Mas não estou usando por não saber como lidar com a table de UsuáriosPorItem
/*
public function addItem($name)
{
$this->items()->create(compact('name'));
}
*/
}