1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Repositories; |
4
|
|
|
|
5
|
|
|
use Adminetic\Website\Models\Admin\About; |
6
|
|
|
use Illuminate\Support\Facades\Cache; |
7
|
|
|
use Adminetic\Website\Contracts\AboutRepositoryInterface; |
8
|
|
|
use Adminetic\Website\Http\Requests\AboutRequest; |
9
|
|
|
|
10
|
|
|
class AboutRepository implements AboutRepositoryInterface |
11
|
|
|
{ |
12
|
|
|
// About Index |
13
|
|
|
public function indexAbout() |
14
|
|
|
{ |
15
|
|
|
$abouts = config('adminetic.caching', true) |
16
|
|
|
? (Cache::has('abouts') ? Cache::get('abouts') : Cache::rememberForever('abouts', function () { |
17
|
|
|
return About::latest()->get(); |
18
|
|
|
})) |
19
|
|
|
: About::latest()->get(); |
20
|
|
|
return compact('abouts'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// About Create |
24
|
|
|
public function createAbout() |
25
|
|
|
{ |
26
|
|
|
// |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// About Store |
30
|
|
|
public function storeAbout(AboutRequest $request) |
31
|
|
|
{ |
32
|
|
|
$about = About::create($request->validated()); |
33
|
|
|
$this->uploadImage($about); |
34
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// About Show |
38
|
|
|
public function showAbout(About $about) |
39
|
|
|
{ |
40
|
|
|
return compact('about'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
// About Edit |
44
|
|
|
public function editAbout(About $about) |
45
|
|
|
{ |
46
|
|
|
return compact('about'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// About Update |
50
|
|
|
public function updateAbout(AboutRequest $request, About $about) |
51
|
|
|
{ |
52
|
|
|
$about->update($request->validated()); |
53
|
|
|
$this->uploadImage($about); |
54
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// About Destroy |
58
|
|
|
public function destroyAbout(About $about) |
59
|
|
|
{ |
60
|
|
|
$about->delete(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
// Upload Image |
64
|
|
|
private function uploadImage(About $about) |
65
|
|
|
{ |
66
|
|
|
if (request()->has('image')) { |
67
|
|
|
$about |
68
|
|
|
->addFromMediaLibraryRequest(request()->image) |
69
|
|
|
->toMediaCollection('image'); |
70
|
|
|
} |
71
|
|
|
if (request()->has('icon_image')) { |
72
|
|
|
$about |
73
|
|
|
->addFromMediaLibraryRequest(request()->icon_image) |
74
|
|
|
->toMediaCollection('icon_image'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|