|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Models\Release; |
|
6
|
|
|
use App\Models\UsersRelease; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Illuminate\Support\Facades\Auth; |
|
9
|
|
|
|
|
10
|
|
|
class CartController extends BasePageController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @throws \Exception |
|
14
|
|
|
*/ |
|
15
|
|
|
public function index() |
|
16
|
|
|
{ |
|
17
|
|
|
$this->setPrefs(); |
|
18
|
|
|
$meta_title = 'My Download Basket'; |
|
19
|
|
|
$meta_keywords = 'search,add,to,cart,download,basket,nzb,description,details'; |
|
20
|
|
|
$meta_description = 'Manage Your Download Basket'; |
|
21
|
|
|
|
|
22
|
|
|
$results = UsersRelease::getCart(Auth::id()); |
|
23
|
|
|
$this->smarty->assign('results', $results); |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
$content = $this->smarty->fetch('cart.tpl'); |
|
|
|
|
|
|
26
|
|
|
$this->smarty->assign(compact('content', 'meta_title', 'meta_keywords', 'meta_description')); |
|
27
|
|
|
$this->pagerender(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param \Illuminate\Http\Request $request |
|
32
|
|
|
* |
|
33
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
|
34
|
|
|
* @throws \Exception |
|
35
|
|
|
*/ |
|
36
|
|
|
public function store(Request $request) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->setPrefs(); |
|
39
|
|
|
$guids = explode(',', $request->input('id')); |
|
40
|
|
|
|
|
41
|
|
|
$data = Release::query()->whereIn('guid', $guids)->select(['id'])->get(); |
|
42
|
|
|
|
|
43
|
|
|
if (empty($data)) { |
|
44
|
|
|
return redirect('/cart/index'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
foreach ($data as $d) { |
|
48
|
|
|
$check = UsersRelease::whereReleasesId($d['id'])->first(); |
|
49
|
|
|
if (empty($check)) { |
|
50
|
|
|
UsersRelease::addCart($this->userdata->id, $d['id']); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return redirect('/cart/index'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string|array $id |
|
59
|
|
|
* |
|
60
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector |
|
61
|
|
|
* @throws \Exception |
|
62
|
|
|
*/ |
|
63
|
|
|
public function destroy($id) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->setPrefs(); |
|
66
|
|
|
$ids = null; |
|
67
|
|
|
if (! empty($id) && ! \is_array($id)) { |
|
68
|
|
|
$ids = explode(',', $id); |
|
69
|
|
|
} elseif (\is_array($id)) { |
|
70
|
|
|
$ids = $id; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (! empty($ids) && UsersRelease::delCartByGuid($ids, $this->userdata->id)) { |
|
74
|
|
|
return redirect('/cart/index'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if (! $id) { |
|
78
|
|
|
return redirect('/cart/index'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
return redirect('/cart/index'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.