Below I have detailed how you should set up your relationships. Make sure that you have $table->timestamps() on your pivot table.
I'm not sure exactly what you're asking, please can you confirm what data you want to get, what constraints you want to use and I'll try and help.
Item Model
public function warehouses() {
return $this->belongsToMany('App\Warehouse', 'warehouse_history', 'item_id', 'warehouse_id')->withTimestamps();
}
Warehouse Model
public function items() {
return $this->belongsToMany('App\Item', 'warehouse_history', 'warehouse_id', 'item_id')->withTimestamps();
}