|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Repositories; |
|
4
|
|
|
|
|
5
|
|
|
use Adminetic\Website\Contracts\AboutRepositoryInterface; |
|
6
|
|
|
use Adminetic\Website\Http\Requests\AboutRequest; |
|
7
|
|
|
use Adminetic\Website\Models\Admin\About; |
|
8
|
|
|
use Illuminate\Support\Facades\Cache; |
|
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
|
|
|
|
|
21
|
|
|
return compact('abouts'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
// About Create |
|
25
|
|
|
public function createAbout() |
|
26
|
|
|
{ |
|
27
|
|
|
// |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
// About Store |
|
31
|
|
|
public function storeAbout(AboutRequest $request) |
|
32
|
|
|
{ |
|
33
|
|
|
$about = About::create($request->validated()); |
|
34
|
|
|
$this->uploadImage($about); |
|
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
|
|
|
// About Destroy |
|
57
|
|
|
public function destroyAbout(About $about) |
|
58
|
|
|
{ |
|
59
|
|
|
$about->delete(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// Upload Image |
|
63
|
|
|
private function uploadImage(About $about) |
|
64
|
|
|
{ |
|
65
|
|
|
if (request()->has('image')) { |
|
66
|
|
|
$about |
|
67
|
|
|
->addFromMediaLibraryRequest(request()->image) |
|
68
|
|
|
->toMediaCollection('image'); |
|
69
|
|
|
} |
|
70
|
|
|
if (request()->has('icon_image')) { |
|
71
|
|
|
$about |
|
72
|
|
|
->addFromMediaLibraryRequest(request()->icon_image) |
|
73
|
|
|
->toMediaCollection('icon_image'); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|