private static function ViewComposerLogs($row) { View::composer('admin::pages.management.users.logs', function ($view) use($row) { $rows = Models\Log::where('admin_users_id', $row->id)->orderBy('id', 'DESC')->get()->each(function ($row) { $row->related_table = str_replace('_', '-', $row->related_table); }); $view->with('rows', $rows); }); }
public function directoryDelete($form, $uploads) { $name = str_replace('..', '', base64_decode(Input::get('name'))); if (empty($name) || !is_dir($uploads . $name)) { return false; } if ($success = File::deleteDirectory($uploads . $name)) { Models\Log::create(['created_at' => date('Y-m-d H:i:s'), 'action' => __FUNCTION__, 'description' => str_replace(public_path(), '', $uploads) . $name, 'admin_users_id' => $this->user->id]); } Session::flash('flash-message', ['message' => __('Directory deleted successfully'), 'status' => 'success']); return $success; }
public function scopeReplace($query, array $data, $row = null, $log = false) { $action = empty($row->id) ? 'insert' : 'update'; foreach ($data as $key => $value) { if (is_array($value)) { continue; } if (empty($value) && strstr($key, '_id')) { $value = null; } $row->{$key} = $value; } $row->save(); if ($log) { Log::register($action, $this->getTable(), $row); } return $row; }