<?php

$rows = [
	0 => [
		'device_id' => 3
		'price' => 321312
		],
	1 => [
		'device_id' => 1,
		'price' => 1123
		]
	];
	
foreach ($rows as $row){
	Validator::make($row, [
    '*.device_id' => ['required', 'integer', 'exists:App\Device,id', Rule::unique('prices')
        ->where('device_id', $row['device_id'])
    ],
    '*.price' => ['required', 'numeric', 'min:0', 'max:16777215'],
])
->validate();
}

foreach ($rows as $row){
	Price::create([
    'device_id' => $row['device_id'],
    'price' => $row['price'],
]);
}
 