|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Afrittella\BackProject\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Afrittella\BackProject\Repositories\Attachments; |
|
6
|
|
|
use Afrittella\BackProject\Repositories\Criteria\Attachments\All; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use Illuminate\Support\Facades\Auth; |
|
9
|
|
|
use Prologue\Alerts\Facades\Alert; |
|
10
|
|
|
|
|
11
|
|
|
class MediaController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
public function __construct() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->middleware('admin'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function index(Attachments $attachments) |
|
19
|
|
|
{ |
|
20
|
|
|
$attachments->pushCriteria(new All()); |
|
21
|
|
|
return view('back-project::media.index')->with('attachments', $attachments->all()); |
|
|
|
|
|
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function edit(Attachments $attachments, $id) |
|
25
|
|
|
{ |
|
26
|
|
|
return view('back-project::media.edit')->with('attachment', $attachments->find($id)); |
|
|
|
|
|
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
View Code Duplication |
public function store(Request $request, Attachments $attachments) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$user = Auth::user(); |
|
32
|
|
|
|
|
33
|
|
|
$success = $attachments->create(array_merge($request->all(), ['user_id' => $user->id])); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
Alert::add('success', trans('back-project::base.image_uploaded'))->flash(); |
|
36
|
|
|
|
|
37
|
|
|
return response()->json([ |
|
38
|
|
|
'success' => true, |
|
39
|
|
|
'message' => trans('back-project::base.image_uploaded') |
|
40
|
|
|
]); |
|
41
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function update(Request $request, Attachments $attachments, $id) |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
$attachment = $attachments->update($request->all(), $id); |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
Alert::add('success', trans('back-project::crud.model_updated', ['model' => trans('back-project::media.image')]))->flash(); |
|
50
|
|
|
|
|
51
|
|
|
return redirect(route('bp.media.index')); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function delete(Attachments $attachments, $id) |
|
55
|
|
|
{ |
|
56
|
|
|
$attachments->delete($id); |
|
57
|
|
|
|
|
58
|
|
|
Alert::add('success', trans('back-project::crud.model_deleted', ['model' => trans('back-project::media.image')]))->flash(); |
|
59
|
|
|
|
|
60
|
|
|
return back(); |
|
61
|
|
|
} |
|
62
|
|
|
} |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: