| xqd
@@ -41,6 +41,11 @@ class SettingsController extends Controller
|
|
|
*/
|
|
|
private function _createSave(){
|
|
|
$data = (array) request('data');
|
|
|
+ $pic = (array) request('value');
|
|
|
+ $data['category'] = 'banner';
|
|
|
+ $data['key'] = '0';
|
|
|
+ $data['pid'] = '0';
|
|
|
+ $data['value'] = $pic[0];
|
|
|
$id = $this->repository->create($data);
|
|
|
if($id) {
|
|
|
$url[] = array('url'=>U( 'setting/banner/index'),'title'=>'返回列表');
|
| xqd
@@ -71,6 +76,15 @@ class SettingsController extends Controller
|
|
|
*/
|
|
|
private function _updateSave() {
|
|
|
$data = (array) request('data');
|
|
|
+ $data2 = $this->repository->find(request('id')) ;
|
|
|
+ $old_pics = $data2->value;
|
|
|
+ $pic = (array) request('value');
|
|
|
+ if (!empty($pic)) {
|
|
|
+ $data['value'] = $pic[0];
|
|
|
+ if (is_file('.'.$old_pics)) {
|
|
|
+ unlink('.'.$old_pics);
|
|
|
+ }
|
|
|
+ }
|
|
|
$ok = $this->repository->update(request('id'),$data);
|
|
|
if($ok) {
|
|
|
$url[] = array('url'=>U( 'setting/banner/index'),'title'=>'返回列表');
|
| xqd
@@ -83,8 +97,13 @@ class SettingsController extends Controller
|
|
|
|
|
|
public function bannerDestroy(Request $request)
|
|
|
{
|
|
|
+ $data2 = $this->repository->find(request('id')) ;
|
|
|
+ $old_pics = $data2->value;
|
|
|
$bool = $this->repository->destroy($request->id);
|
|
|
if($bool) {
|
|
|
+ if (is_file('.'.$old_pics)) {
|
|
|
+ unlink('.'.$old_pics);
|
|
|
+ }
|
|
|
return $this->showMessage('操作成功');
|
|
|
}else {
|
|
|
return $this->showWarning("操作失败");
|