Fix logic and add check for duplicated data

This commit is contained in:
DariusIII
2019-03-21 14:26:13 +01:00
parent f99515f185
commit 51dc52816f
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -1,4 +1,5 @@
2019-03-21 DariusIII
* Fix: Fix logic and add check for duplicated data
* Chg: Use separate query to add releases to cart as we only need the id, so no need to use heavier getByGuid function
* Chg: Update font-awesome to latest version
* Chg: Update rtconner/laravel-tagging (3.1.0 => 3.1.1), wildbit/swiftmailer-postmark (3.0.1 => 3.0.2)
+6 -2
View File
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Release;
use App\Models\UsersRelease;
use Illuminate\Database\QueryException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -40,12 +41,15 @@ class CartController extends BasePageController
$data = Release::query()->whereIn('guid', $guids)->select(['id'])->get();
if (! empty($data)) {
if (empty($data)) {
return redirect('/cart/index');
}
foreach ($data as $d) {
UsersRelease::addCart($this->userdata->id, $d['id']);
$check = UsersRelease::whereReleasesId($d['id'])->first();
if (empty($check)) {
UsersRelease::addCart($this->userdata->id, $d['id']);
}
}
return redirect('/cart/index');
}