restore composer.json, add mysqli extension
This commit is contained in:
21
app/Services/Dashboard/Region/RegionService.php
Executable file
21
app/Services/Dashboard/Region/RegionService.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Dashboard\Region;
|
||||
|
||||
use App\Models\Region;
|
||||
|
||||
class RegionService
|
||||
{
|
||||
public static function deliveryPrice(Region $region, $data)
|
||||
{
|
||||
$toDelete = $region->deliveryPrice()->whereNotIn('power_id', array_column($data, 'power_id'))->get();
|
||||
$toDelete->each->delete();
|
||||
|
||||
foreach ($data as $item) {
|
||||
$region->deliveryPrice()->updateOrCreate(
|
||||
['power_id' => $item['power_id']],
|
||||
['price' => $item['price']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user