fix: when uploading for a full group
This commit is contained in:
parent
325740f054
commit
fcb54717ed
|
|
@ -9,6 +9,8 @@ use Maatwebsite\Excel\Facades\Excel;
|
||||||
use App\Http\Resources\SubgroupResource;
|
use App\Http\Resources\SubgroupResource;
|
||||||
use App\Imports\TradingsImport;
|
use App\Imports\TradingsImport;
|
||||||
use App\Models\Subgroup;
|
use App\Models\Subgroup;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class TradingController extends Controller
|
class TradingController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +77,18 @@ class TradingController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$group->tradings()->whereLocale(app()->getLocale())->delete();
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$group->tradings()->whereLocale(app()->getLocale())->delete();
|
||||||
|
$group->subgroups()->whereLocale(app()->getLocale())->delete();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Log::info($th);
|
||||||
|
DB::rollback();
|
||||||
|
return redirect()->route('tradings');
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = now()->unix();
|
$id = now()->unix();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,11 @@ class Group extends Model
|
||||||
return $this->hasMany(Import::class);
|
return $this->hasMany(Import::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function subgroups()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Subgroup::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function getFilenameAttribute()
|
public function getFilenameAttribute()
|
||||||
{
|
{
|
||||||
$locale = app()->getLocale();
|
$locale = app()->getLocale();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue