1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Tool; |
4
|
|
|
|
5
|
|
|
use App\Models\Eloquent\Tool\ImageHosting; |
6
|
|
|
use App\Models\Eloquent\User; |
7
|
|
|
use App\Http\Controllers\Controller; |
8
|
|
|
use Auth; |
9
|
|
|
|
10
|
|
|
class ImageHostingController extends Controller |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Show the Image Hosting Create Page. |
14
|
|
|
* |
15
|
|
|
* @return Response |
|
|
|
|
16
|
|
|
*/ |
17
|
|
|
public function create() |
18
|
|
|
{ |
19
|
|
|
return view('tool.imagehosting.create', [ |
|
|
|
|
20
|
|
|
'page_title' => "Create", |
21
|
|
|
'site_title' => "Image Hosting", |
22
|
|
|
'navigation' => "Image Hosting", |
23
|
|
|
'permission' => Auth::user()->hasPermission(26) |
|
|
|
|
24
|
|
|
]); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Show the Image Hosting Detail Page. |
29
|
|
|
* |
30
|
|
|
* @return Response |
31
|
|
|
*/ |
32
|
|
|
public function detail($id) |
33
|
|
|
{ |
34
|
|
|
$image=ImageHosting::find($id); |
35
|
|
|
if (is_null($image)) { |
36
|
|
|
return abort('404'); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
if (Auth::user()->id!=$image->user_id) { |
|
|
|
|
39
|
|
|
return abort('403'); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
return view('tool.imagehosting.detail', [ |
|
|
|
|
42
|
|
|
'page_title' => "Detail", |
43
|
|
|
'site_title' => "Image Hosting", |
44
|
|
|
'navigation' => "Image Hosting", |
45
|
|
|
'image' => $image, |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Show the Image Hosting List Page. |
51
|
|
|
* |
52
|
|
|
* @return Response |
53
|
|
|
*/ |
54
|
|
|
public function list() |
55
|
|
|
{ |
56
|
|
|
$images=Auth::user()->imagehostings()->orderBy('created_at', 'desc')->get(); |
|
|
|
|
57
|
|
|
return view('tool.imagehosting.list', [ |
|
|
|
|
58
|
|
|
'page_title' => "List", |
59
|
|
|
'site_title' => "Image Hosting", |
60
|
|
|
'navigation' => "Image Hosting", |
61
|
|
|
'images' => $images, |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|