本文整理汇总了PHP中Configure::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::valid方法的具体用法?PHP Configure::valid怎么用?PHP Configure::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configure
的用法示例。
在下文中一共展示了Configure::valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateConfigure
public function updateConfigure()
{
if (Input::has('pk')) {
if (!Request::ajax()) {
return App::abort(404);
}
return self::updateQuickEdit();
} else {
if (Request::ajax()) {
$arrReturn = ['status' => 'error'];
$configure = new Configure();
$configure->cname = Input::get('cname');
$configure->ckey = Input::get('ckey');
if (Input::hasFile('cvalue')) {
$path = app_path('files');
if (!File::exists($path)) {
File::makeDirectory($path, 493, true);
}
$path = str_replace(['\\', '/'], DS, $path);
$file = Input::file('cvalue');
$file->move($path, $configure->ckey . '.' . $file->getClientOriginalExtension());
$configure->cvalue = $path . DS . $configure->ckey . '.' . $file->getClientOriginalExtension();
} else {
$configure->cvalue = Input::get('cvalue');
}
$configure->cdescription = Input::get('cdescription');
$configure->active = Input::has('active') ? 1 : 0;
$pass = $configure->valid();
if ($pass) {
$configure->save();
$arrReturn = ['status' => 'ok'];
$arrReturn['message'] = $configure->cname . ' has been saved';
$arrReturn['data'] = $configure;
} else {
$arrReturn['message'] = '';
$arrErr = $pass->messages()->all();
foreach ($arrErr as $value) {
$arrReturn['message'] .= "{$value}\n";
}
}
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}
}
$arrPost = Input::all();
unset($arrPost['_token']);
foreach ($arrPost as $key => $value) {
if (in_array($key, ['main_logo', 'favicon'])) {
if (!Input::hasFile($key)) {
continue;
}
if ($key == 'main_logo') {
$path = public_path('assets' . DS . 'images' . DS . 'logos');
$width = 400;
$name = 'logo';
} else {
if ($key == 'favicon') {
$path = public_path('assets' . DS . 'images' . DS . 'favicons');
$width = 16;
$name = 'favicon';
}
}
$configure = Configure::firstOrNew(['ckey' => $key]);
$configure->ckey = $key;
$configure->cname = Str::title(str_replace('_', ' ', $key));
if (!empty($configure->cvalue) && File::exists(public_path($configure->cvalue))) {
File::delete(public_path($configure->cvalue));
}
$path = VIImage::upload(Input::file($key), $path, $width, false, $name);
$path = str_replace(public_path() . DS, '', $path);
$configure->cvalue = str_replace(DS, '/', $path);
$configure->save();
} else {
$configure = Configure::firstOrNew(['ckey' => $key]);
$configure->ckey = $key;
$configure->cname = Str::title(str_replace('_', ' ', $key));
$configure->cvalue = $value;
$configure->save();
if ($key == 'mask') {
Cache::tags('images')->flush();
Cache::forever('mask', $value);
}
}
}
return Redirect::to(URL . '/admin/configures')->with('flash_success', 'Main Configure has been saved.');
}