本文整理汇总了PHP中App\Http\Controllers\Log::notice方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::notice方法的具体用法?PHP Log::notice怎么用?PHP Log::notice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Log
的用法示例。
在下文中一共展示了Log::notice方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit(Request $request)
{
if (!\Session::get('user')->can('硬件管理')) {
abort(401);
}
$hardware = Hardware::find($request->input('id'));
$old_attributes = $hardware->attributesToArray();
$hardware->name = $request->input('name');
$hardware->description = $request->input('description');
$hardware->model = $request->input('model');
$hardware->self_produce = (bool) ($request->input('self_produce') == 'on');
$new_attributes = $hardware->attributesToArray();
$user = \Session::get('user');
foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) {
$old = $old_attributes[$key];
$new = $new_attributes[$key];
if ($key == 'self_produce') {
$old = $old == 'true' ? '自产' : '外采';
$new = $new == 'true' ? '自产' : '外采';
}
\Log::notice(strtr('硬件修改: 用户(%name[%id]) 修改了硬件 (%hardware[%hardware_id]) 的基本信息: [%key] %old --> %new', ['%name' => $user->name, '%id' => $user->id, '%hardware' => $hardware->name, '%hardware_id' => $hardware->id, '%key' => $key, '%old' => $old, '%new' => $new]));
}
$hardware->save();
return redirect()->back()->with('message_content', '修改成功!')->with('message_type', 'info');
}
示例2: deploy
/**
* Application deploy.
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function deploy(Request $request)
{
list($algo, $hash) = explode('=', $request->header('X-Hub-Signature'), 2);
if (!hash_equals($hash, hash_hmac($algo, $request->getContent(), config('services.github-webhook.secret')))) {
\Log::notice('Github Webhook', ['auth' => 'failed', 'ip' => $request->ip()]);
} else {
\Log::info('Github Webhook', ['auth' => 'success', 'ip' => $request->ip()]);
\Artisan::queue('deploy');
}
return response()->json('', 200);
}
示例3: delete
public function delete($id)
{
if (!\Session::get('user')->can('产品信息管理')) {
abort(401);
}
$product = Product::find($id);
$product_name = $product->name;
$product_id = $product->id;
if ($product->delete()) {
$user = \Session::get('user');
\Log::notice(strtr('产品删除: 用户(%name[%id]) 删除产品 (%product[%product_id])', ['%name' => $user->name, '%id' => $user->id, '%product' => $product_name, '%product_id' => $product_id]));
return redirect()->route('products')->with('message_content', '删除成功!')->with('message_type', 'info');
}
}
示例4: edit
public function edit(Request $request)
{
$user = \Session::get('user');
if (!$user->can('产品模块管理')) {
abort(401);
}
$module = Module::find($request->input('module_id'));
$old_attributes = $module->attributesToArray();
$module->name = $request->input('name');
$module->description = $request->input('description');
$module->save();
$new_attributes = $module->attributesToArray();
$product = $module->product;
foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) {
\Log::notice(strtr('产品模块修改: 用户(%name[%id]) 修改了产品 (%product[%product_id]) 的模块 (%module[%module_id])基本信息: [%key] %old --> %new', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%key' => $key, '%old' => $old_attributes[$key], '%new' => $new_attributes[$key]]));
}
$old_deped_modules = $module->dep_modules->lists('id')->all();
if (count($old_deped_modules)) {
$module->dep_modules()->detach($old_deped_modules);
}
$new_deped_modules = $request->input('modules', []);
$d1 = array_diff($new_deped_modules, $old_deped_modules);
$d2 = array_diff($old_deped_modules, $new_deped_modules);
if (count($d1)) {
$dep_modules = [];
foreach ($d1 as $id) {
$m = Module::find($id);
$dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]);
}
//新加的模块
\Log::notice(strtr('产品模块修改: 用户(%name[%id]) 增加了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)]));
}
if (count($d2)) {
$dep_modules = [];
foreach ($d2 as $id) {
$m = Module::find($id);
$dep_modules[] = strtr('(%name[%id])', ['%name' => $m->name, '%id' => $m->id]);
}
//删除的模块
\Log::notice(strtr('产品模块修改: 用户(%name[%id]) 删除了产品 (%product[%product_id]) 的模块 (%module[%module_id]) 的依赖模块 %dep_modules', ['%name' => $user->name, '%id' => $user->id, '%product' => $product->name, '%product_id' => $product->id, '%module' => $module->name, '%module_id' => $module->id, '%dep_modules' => implode(',', $dep_modules)]));
}
foreach ($new_deped_modules as $module_id) {
$dep_module = Module::find($module_id);
$module->dep_modules()->save($dep_module);
}
return redirect()->back()->with('message_content', '修改成功!')->with('message_type', 'info');
}
示例5: delete
public function delete($id)
{
if (!\Session::get('user')->can('服务器信息管理')) {
abort(401);
}
$server = Server::find($id);
$server_name = $server->name;
$server_id = $server->id;
$server->delete();
$user = \Session::get('user');
\Log::notice(strtr('服务器删除: 用户(%name[%id]) 删除了服务器 (%server[%server_id])', ['%name' => $user->name, '%id' => $user->id, '%server' => $server_name, '%server_id' => $server_id]));
return redirect()->to(route('servers'))->with('message_content', '删除成功!')->with('message_type', 'info');
}
示例6: param_edit
public function param_edit($id, Request $request)
{
$user = \Session::get('user');
if (!$user->can('产品参数管理')) {
abort(401);
}
$sub = SubProduct::find($id);
$param_id = $request->input('param_id');
$param = \App\Param::find($param_id);
//获取子产品中该参数关联的 value
$old_value = $sub->params()->where('param_id', $param->id)->first()->pivot->value;
if ($request->input('reset') == 'on') {
//获取到 product 中该参数的 value
$value = $sub->product->params()->where('id', $param->id)->first()->value;
$param->value = $value;
$sub->params()->detach($param_id);
$sub->params()->save($param, ['value' => $value]);
\Log::notice(strtr('子产品参数修改: 用户 (%name[%id]) 修改了子产品 (%product_name[%product_id] 的参数(%param_name[%param_id]) : %old_value -> %new_value', ['%name' => $user->name, '%id' => $user->id, '%product_name' => $sub->name, '%product_id' => $sub->id, '%param_name' => $param->name, '%param_id' => $param->id, '%old_value' => $old_value, '%new_value' => $value]));
} else {
$value = $request->input('value');
$sub->params()->updateExistingPivot($param_id, ['value' => $value, 'manual' => true]);
\Log::notice(strtr('子产品参数修改: 用户 (%name[%id]) 修改了子产品 (%product_name[%product_id] 的参数(%param_name[%param_id]) : %old_value -> %new_value', ['%name' => $user->name, '%id' => $user->id, '%product_name' => $sub->name, '%product_id' => $sub->id, '%param_name' => $param->name, '%param_id' => $param->id, '%old_value' => $old_value, '%new_value' => $value]));
}
foreach ($sub->projects as $project) {
$project_param = $project->params()->where('param_id', $param->id)->first();
$old_value = $project_param->pivot->value;
//如果为默认 (不为手动), 则修改
if (!$project_param->pivot->manual) {
$project->params()->updateExistingPivot($param->id, ['value' => $value]);
\Log::notice(strtr('项目参数修改: 用户 (%name[%id]) 修改了项目 (%project_name[%project_id] 的参数(%param_name[%param_id]) : %old_value -> %new_value', ['%name' => $user->name, '%id' => $user->id, '%project_name' => $project->name, '%project_id' => $project->id, '%param_name' => $param->name, '%param_id' => $param->id, '%old_value' => $old_value, '%new_value' => $value]));
}
}
return redirect()->back()->with('message_content', '参数修改成功!')->with('message_type', 'info');
}
示例7: edit
public function edit(Request $request)
{
$user = \Session::get('user');
if (!$user->can('项目硬件部署管理')) {
abort(401);
}
$item = HardwareItem::find($request->input('id'));
$project = $item->project;
$hardware = $item->hardware;
$old_attributes = $item->attributesToArray();
$item->status = $request->input('status');
$item->extra = $request->input('fields', []);
$item->ref_no = $request->input('ref_no');
$time = $request->input('time');
if (!$time) {
$time = null;
} else {
$time = \Carbon\Carbon::createFromFormat('Y/m/d', $time)->format('Y-m-d H:i:s');
}
$item->time = $time;
$item->save();
$new_attributes = $item->attributesToArray();
$old_extra = $old_attributes['extra'];
$new_extra = $new_attributes['extra'];
$change = [];
foreach (array_diff_assoc($old_extra, $new_extra) as $key => $value) {
if (isset($old_extra[$key])) {
$old_extra_value = $old_extra[$key];
} else {
$old_extra_value = null;
}
if (isset($new_extra[$key])) {
$new_extra_value = $new_extra[$key];
} else {
$new_extra_value = null;
}
$title = HardwareField::find($key)->name;
\Log::notice(strtr('项目硬件明细修改: 用户(%name[%id]) 修改了项目(%project_name[%project_id]) 硬件 (%hardware_name[%hardware_id]) 的 自定义明细信息: %title[%key] : %old -> %new', ['%name' => $user->name, '%id' => $user->id, '%project_name' => $project->name, '%project_id' => $project->id, '%hardware_name' => $hardware->name, '%hardware_id' => $hardware->id, '%hardware_item_id' => $item->id, '%key' => $key, '%title' => $title, '%old' => $old_extra_value, '%new' => $new_extra_value]));
$change[] = ['title' => $title, 'old' => $old_extra_value, 'new' => $new_extra_value];
}
if (count($change)) {
array_unshift($change, ['title' => strtr('硬件 (%hardware_name) 下新的硬件明细 %item_id', ['%hardware_name' => $hardware->name, '%item_id' => $item->id])]);
Clog::add($project, '项目硬件明细修改', $change, Clog::LEVEL_INFO);
}
$helper = ['time' => '操作时间', 'status' => '状态', 'ref_no' => '硬件序号'];
$change = [];
unset($old_attributes['extra']);
unset($new_attributes['extra']);
foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) {
$old_value = $old_attributes[$key];
$new_value = $new_attributes[$key];
switch ($key) {
case 'status':
$new_value = \App\HardwareItem::$status[$new_value];
$old_value = \App\HardwareItem::$status[$old_value];
break;
case 'time':
if ($new_value) {
$new_value = $new_value->format('Y/m/d');
}
if ($old_value) {
$old_value = $old_value->format('Y/m/d');
}
//时间需要特殊处理
if ($old_value == $new_value) {
continue 2;
}
break;
}
$change[$key] = ['old' => $old_value, 'new' => $new_value, 'title' => $helper[$key]];
}
if (count($change)) {
foreach ($change as $c) {
\Log::notice(strtr('项目硬件明细修改: 用户(%name[%id]) 修改了项目(%project_name[%project_id]) 硬件 (%hardware_name[%hardware_id]) 的 明细信息: %hardware_item_id, %title : %old -> %new', ['%name' => $user->name, '%id' => $user->id, '%project_name' => $project->name, '%project_id' => $project->id, '%hardware_name' => $hardware->name, '%hardware_id' => $hardware->id, '%hardware_item_id' => $item->id, '%title' => $c['title'], '%old' => $c['old'], '%new' => $c['new']]));
}
array_unshift($change, ['title' => strtr('硬件 (%hardware_name) 下新的硬件明细 %item_id', ['%hardware_name' => $hardware->name, '%item_id' => $item->id])]);
Clog::add($project, '项目硬件明细修改', $change, Clog::LEVEL_INFO);
}
return redirect()->to(route('project.profile', ['id' => $item->project->id]))->with('message_type', 'info')->with('message_content', '修改部署硬件成功!')->with('tab', 'hardwares');
}
示例8: hardware_edit
public function hardware_edit($id, Request $request)
{
$user = \Session::get('user');
if (!$user->can('项目硬件管理')) {
abort(401);
}
$hardware_id = $request->input('hardware_id');
$hardware = Hardware::find($hardware_id);
$project = Project::find($id);
$h = $project->hardwares()->where('hardware_id', $hardware_id)->first();
$old = ['description' => $h->pivot->description, 'count' => $h->pivot->count];
$new = ['description' => $request->input('description'), 'count' => $request->input('count')];
$project->hardwares()->detach($hardware_id);
$project->hardwares()->save($hardware, $new);
$change = [];
$diff_helper = ['description' => '描述', 'count' => '计划部署数量'];
foreach (array_keys($diff_helper) as $item) {
if ($old[$item] != $new[$item]) {
$change[] = ['old' => $old[$item], 'new' => $new[$item], 'title' => $diff_helper[$item]];
}
}
if (count($change)) {
foreach ($change as $c) {
\Log::notice(strtr('项目关联硬件信息修改: 用户(%name[%id]) 修改了项目(%project_name[%project_id]) 关联硬件的信息: %title %old -> %new', ['%name' => $user->name, '%id' => $user->id, '%project_name' => $project->name, '%project_id' => $project->id, '%title' => $c['title'], '%old' => $c['old'], '%new' => $c['new']]));
}
array_unshift($change, ['title' => strtr('项目硬件: %hardware_name', ['%hardware_name' => $hardware->name])]);
Clog::add($project, '关联硬件基本信息修改', $change, Clog::LEVEL_WARNING);
}
return redirect()->back()->with('message_content', '硬件修改成功!')->with('message_type', 'info')->with('tab', 'hardwares');
}
示例9: upload
public function upload($project_id, Request $request)
{
$user = \Session::get('user');
if (!$user->can('项目文件管理')) {
abort(401);
}
$project = Project::find($project_id);
if ($request->hasFile('file')) {
$path = $request->input('path');
$file = $request->file('file')->getClientOriginalName();
$full_path = \App\NFS::full_path($project, $path);
$full_file = \App\NFS::full_path($project, $path . '/' . $file);
if (file_exists($full_file)) {
$dirname = dirname($full_file) . '/';
$info = \App\NFS::pathinfo($full_file);
$extension = $info['extension'] ? '.' . $info['extension'] : '';
$name = substr($file, 0, strrpos($file, '.') ?: strlen($file));
$suffix_count = 2;
do {
$file_name = $name . '(' . $suffix_count . ')' . $extension;
$full_file = $dirname . $file_name;
++$suffix_count;
} while (file_exists($full_file));
}
$file = substr($full_file, strrpos($full_file, '/') + 1);
\Log::notice(strtr('文件上传: 用户(%name[%id]) 在路径 %path 中上传了文件 %file', ['%name' => $user->name, '%id' => $user->id, '%path' => $full_path, '%file' => $file]));
$request->file('file')->move($full_path, $file);
return redirect()->back()->with('message_content', '上传成功!')->with('message_type', 'info');
} else {
return redirect()->back()->with('message_content', '上传失败')->with('message_type', 'danger');
}
}
示例10: delete
public function delete($id)
{
$user = \Session::get('user');
if (!$user->can('产品参数管理')) {
abort(401);
}
$param = Param::find($id);
$param_name = $param->name;
$param_id = $param->id;
$param_value = $param->value;
$product = $param->product;
//softDelete, 删除后会 hide, 不用在其他的地方进行修改
$param->delete();
\Log::notice(strtr('产品参数删除: 用户 (%name[%id]) 删除了产品 (%product_name[%product_id] 的参数(%param_name[%param_id]) : %value', ['%name' => $user->name, '%id' => $user->id, '%product_name' => $product->name, '%product_id' => $product->id, '%param_name' => $param_name, '%param_id' => $param_id, '%value' => $param_value]));
return redirect()->back()->with('message_content', '删除成功!')->with('message_type', 'info');
}
示例11: edit
public function edit(Request $request)
{
$me = \Session::get('user');
if (!$me->can('项目外出记录管理')) {
abort(401);
}
$record = Record::find($request->input('id'));
$project = $record->project;
$user = User::find($request->input('user_id'));
$record->user()->associate($user);
$old_attributes = $record->attributesToArray();
$time = $request->input('time');
if (!$time) {
$time = null;
} else {
$time = \Carbon\Carbon::createFromFormat('Y/m/d', $time)->format('Y-m-d H:i:s');
}
$record->time = $time;
$record->content = $request->input('content');
$record->contact = $request->input('contact');
$record->phone = $request->input('phone');
$record->software_count = $request->input('software_count');
$record->hardware_name = $request->input('hardware_name');
$record->hardware_count = $request->input('hardware_count');
$record->save();
$new_attributes = $record->attributesToArray();
foreach (array_diff_assoc($old_attributes, $new_attributes) as $key => $value) {
$changed = false;
$old_value = $old_attributes[$key];
if ($old_value == null) {
$old_value = '空';
}
$new_value = $new_attributes[$key];
if ($new_value == null) {
$new_value = '空';
}
switch ($key) {
case 'time':
if ($old_value->format('Y/m/d') != $new_value->format('Y/m/d')) {
$changed = true;
}
break;
default:
$changed = true;
}
if ($changed) {
\Log::notice(strtr('外出记录修改: 用户(%name[%id]) 修改了项目 %project[%project_id] 的外出记录 %record_id: %key : %old --> %new', ['%name' => $me->name, '%id' => $me->id, '%project' => $project->name, '%project_id' => $project->id, '%record_id' => $record->id, '%key' => $key, '%old' => $old_value, '%new' => $new_value]));
}
}
return redirect()->back()->with('message_content', '外出记录修改成功!')->with('message_type', 'info')->with('tab', 'records');
}