first change
This commit is contained in:
53
Modules/Admin/app/Repositories/SettingRepository.php
Normal file
53
Modules/Admin/app/Repositories/SettingRepository.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Admin\Repositories;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Admin\Models\Setting;
|
||||
|
||||
class SettingRepository implements SettingInterface
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return Setting::get()->mapWithKeys(function ($setting) {
|
||||
return [$setting->key => $setting->value];
|
||||
});
|
||||
}
|
||||
|
||||
public function getSettingById($SettingId)
|
||||
{
|
||||
return Setting::findOrFail($SettingId);
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
return Setting::pluck('title', 'id');
|
||||
}
|
||||
|
||||
public function delete($SettingId)
|
||||
{
|
||||
Setting::destroy($SettingId);
|
||||
}
|
||||
public function create(array $settingDetails, Request $request)
|
||||
{
|
||||
$thumbName = time() . '.' . $request->file('thumb')->extension();
|
||||
$logoName = uniqid() . '.' . $request->file('logo')->extension();
|
||||
|
||||
$request->thumb->move(public_path('images/setting'), $thumbName);
|
||||
$request->logo->move(public_path('images/setting'), $logoName);
|
||||
|
||||
$path = 'images/setting/';
|
||||
$settingDetails['logo'] = $path . $logoName;
|
||||
$settingDetails['thumb'] = $path . $thumbName;
|
||||
|
||||
// dd($settingDetails);
|
||||
return Setting::create($settingDetails);
|
||||
}
|
||||
|
||||
public function update($SettingId, $newDetails)
|
||||
{
|
||||
$setting = Setting::where('id', $SettingId);
|
||||
|
||||
$setting->update($newDetails);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user