Example #1
0
	public static function create_log($user_id,$module_type,$content){
		$log = new Log;
		$log->user_id = $user_id;
		$log->module_type = $module_type;
		$log->content = $content;
		$log->save();
	}
Example #2
0
 /**
  * Logs an action.
  *
  * @param  string  $action
  * @param  App\Board|String  $board
  * @param  Array $data
  * @return App\Log
  */
 public function log($action, $board = null, $data = null)
 {
     $board_uri = null;
     $action_details = null;
     if ($board instanceof \App\Board) {
         $board_uri = $board->board_uri;
         $action_details = $data;
     } else {
         if ($board instanceof \App\Post) {
             $board_uri = $board->board_uri;
             $action_details = $data;
         } else {
             if (is_string($board)) {
                 $board_uri = $board;
                 $action_details = $data;
             } else {
                 if (is_array($board) && is_null($data)) {
                     $board_uri = null;
                     $action_details = $board;
                 }
             }
         }
     }
     if (!is_null($action_details) && !is_array($action_details)) {
         $action_details = [$action_details];
     }
     if (!is_null($action_details)) {
         $action_details = json_encode($action_details);
     }
     $log = new Log(['action_name' => $action, 'action_details' => $action_details, 'user_id' => $this->user->isAnonymous() ? null : $this->user->user_id, 'user_ip' => Request::getClientIp(), 'board_uri' => $board_uri]);
     return $log->save();
 }
Example #3
0
 public function add($action, $message, $user = null)
 {
     $log = new Log();
     $log->message = "{$action} : {$message}";
     if (is_object($user) && hasEntry("id", $user)) {
         $log->user_id = $user->id;
     }
     $log->save();
 }
Example #4
0
 public function destroy($id, User $user)
 {
     $stop = Stop::find($id);
     $log = new Log();
     $log->user_id = $user->id;
     $log->log = "删除车站" . print_r($stop->toArray(), true);
     $log->save();
     Stop::destroy($id);
     return redirect()->action('StopController@index');
 }
Example #5
0
 public function destroy($id, User $user)
 {
     $rank = Rank::find($id);
     $log = new Log();
     $log->user_id = $user->id;
     $log->log = "删除等级" . print_r($rank->toArray(), true);
     $log->save();
     Rank::destroy($id);
     return redirect()->action('RankController@index');
 }
Example #6
0
 public function destroy($id, User $user)
 {
     $help = Help::find($id);
     $log = new Log();
     $log->user_id = $user->id;
     $log->log = "删除帮助" . print_r($help->toArray(), true);
     $log->save();
     Help::destroy($id);
     return redirect()->action('AdminController@getHelp');
 }
Example #7
0
 public function destroy($id, User $user)
 {
     $bike = Bike::find($id);
     $log = new Log();
     $log->user_id = $user->id;
     $log->log = "删除单车" . print_r($bike->toArray(), true);
     dd($log->log);
     $log->save();
     Bike::destroy($id);
     return redirect()->action('BikeController@index');
 }
 public function store(Request $request)
 {
     $log = new Log();
     $log->email = $request->email;
     $log->industry = $request->industry;
     $log->report = $request->report;
     $log->saleprice = $request->saleprice;
     $log->proposals = $request->proposals;
     $log->save();
     return view('templates.success');
 }
Example #9
0
 public function questionDel(Request $request)
 {
     Question::find($request->get('id'))->delete();
     Question::where('subId', $request->get('id'))->delete();
     $log = new Log();
     $log->memberId = Auth::user()->id;
     $log->detail = 'Delete Post,' . $request->get('id');
     $log->save();
     if ($request->get('redirect') == '') {
         return redirect(route('home'));
     } else {
         return redirect(html_entity_decode($request->get('redirect')));
     }
 }
Example #10
0
 public function getAction($post = null, $action = null)
 {
     $post = Post::find($post);
     if (!$post) {
         app()->abort(422);
     }
     if ($action) {
         // Log action and push to queue
         $log = Log::firstOrNew(['reason' => $action, 'market_item_id' => $post->market()->whereAction($action)->first()->id]);
         if (!$log->id) {
             Auth::user()->log()->save($log);
             $job = (new AwaitAction($log))->onQueue('check');
             $this->dispatch($job);
         } else {
             return ['error' => trans('app.action_duplicate')];
         }
     }
     if (!$post) {
         return ['success' => true];
     }
     $url = !$action ? false : $this->social->with($post->provider)->action($action, $post->provider_id);
     if ($url === true) {
         return ['success' => true];
     }
     if (!$url || !parse_url($url)) {
         $url = $post->link;
     }
     return ['success' => true, 'redirect' => $url];
 }
Example #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Activity::find($id);
     $item->status = 'deleted';
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Activities named " . $item->name));
 }
Example #12
0
 /**
  * Gets all att. record from the connected device and no
  * sorting is applied. Returns only the new ones.
  * @return [type] [description]
  */
 public function getAll()
 {
     if ($this->tad && $this->tad->is_alive()) {
         $data = $this->tad->get_att_log()->to_array();
         $data = $data['Row'];
         // $device = Device::where('ip_address', $this->connected_device['ip_address'])->first();
         $last_log = Log::where('device_id', $this->connected_device['device_id'])->orderBy('id', 'desc')->first();
         $last_log_datetime = null;
         if ($last_log) {
             $last_log_datetime = Carbon::parse($last_log->datetime);
         }
         $return_data = [];
         $timestamp = Carbon::now()->toDateTimeString();
         foreach ($data as $k => $v) {
             if ($last_log_datetime === null || $last_log_datetime->lt(Carbon::parse($data[$k]['DateTime']))) {
                 $data[$k]['emp_id'] = $data[$k]['PIN'];
                 unset($data[$k]['PIN']);
                 $data[$k]['datetime'] = $data[$k]['DateTime'];
                 unset($data[$k]['DateTime']);
                 $data[$k]['verified'] = $data[$k]['Verified'];
                 unset($data[$k]['Verified']);
                 $data[$k]['status'] = $data[$k]['Status'];
                 unset($data[$k]['Status']);
                 $data[$k]['workcode'] = $data[$k]['WorkCode'];
                 unset($data[$k]['WorkCode']);
                 $data[$k]['device_id'] = $this->connected_device['device_id'];
                 $data[$k]['created_at'] = $timestamp;
                 $data[$k]['updated_at'] = $timestamp;
                 array_push($return_data, $data[$k]);
             }
         }
         return $return_data;
     }
 }
Example #13
0
 public function getLog(User $user)
 {
     if (!($user->auth & \Config::get('admin.adminLog'))) {
         return response(view('errors.error', ['title' => '权限不足', 'error' => '您没有管理后台日志的权限!']), 403);
     }
     return view('admin.log')->withLog(Log::orderBy('id', 'DESC')->paginate(20))->withUser($user);
 }
Example #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Source::find($id);
     $item->status = "deleted";
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Source named " . $item->name));
 }
Example #15
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $logs = Log::find($id);
     if (\Request::wantsJson()) {
         return $logs->toJson();
     }
     dd($logs->toArray());
 }
Example #16
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::get();
     #Category
     foreach (range(1, 20) as $void) {
         Log::create(['user_id' => $users->random(1)->id, 'type' => $faker->text(10), 'source_id' => $faker->numberBetween(50, 1000000), 'details' => $faker->text(50)]);
     }
 }
 /**
  * Recalculates score based on current vote composition.
  *
  * @return Description
  */
 protected function updateScore()
 {
     $votes = $this->vote_ups + $this->vote_downs;
     $ratio = $this->vote_downs > 0 ? $this->vote_ups / $this->vote_downs : 1;
     $score = round($votes * $ratio, 2);
     \Log::info($this->id . ': ' . $score);
     $this->score = $score;
     return $this;
 }
 public function getIndex()
 {
     $users = User::all();
     $entities = Semantics::GetAllEntities();
     $logs = Log::all()->sortByDesc('created_at')->forPage(1, self::NB_LOGS_SHOWN);
     $comments = Comments::LoadComment();
     $cComments = collect($comments);
     $data = array('users' => $users, 'entities' => $entities, 'logs' => $logs, 'comments' => $comments, 'nbCommentNotValidated' => $cComments->where("validated", false)->count());
     return view('admin/admin')->with($data);
 }
Example #19
0
 public function savelog()
 {
     $equation = Input::get('equation');
     $id = Input::get('id');
     $status = Input::get('status');
     $mood = Input::get('mood');
     $log = array('equation' => $equation, 'equation_id' => $id, 'status' => $status, 'emotion' => $mood);
     $model = Log::create($log);
     // dd($model);
 }
Example #20
0
 public function run()
 {
     $faker = Faker::create();
     $actions = ActionType::get();
     $users = User::select('id')->get();
     //Category
     foreach (range(1, 20) as $void) {
         Log::create(['user_id' => $users->random(1)->id, 'action_type_id' => $actions->random(1)->id, 'source_id' => $faker->numberBetween(50, 1000000), 'details' => $faker->text(50)]);
     }
 }
Example #21
0
 public function getPointsAttribute()
 {
     $id = $this->attributes['id'];
     return Cache::remember("user_{$id}_points", 3, function () use($id) {
         $marketActions = Log::with('market')->whereFlag(true)->where('user_id', $id)->get()->sum('market.reward');
         $otherActions = Log::where('user_id', $id)->whereFlag(true)->whereNull('market_item_id')->get()->sum('reward');
         $reduced = $this->reduced->select('market.reward')->sum('market.reward');
         return $marketActions + $otherActions - $reduced;
     });
 }
 public function store(StoreCommentRequest $request)
 {
     // TODO: findOrFail ile kontrol et. ModelNotFoundException'ı handle'a ekle.
     if (!Log::find($request->log_id)) {
         return redirect()->back();
     }
     // TODO: Bu işlemi CommentObserver'da yap.
     $request->merge(['user_id' => auth()->user()->id]);
     Comment::create($request->all());
     return redirect()->back();
 }
 public static function registroPersonaTicket($idPersona, $id_ticket, $idUsuCrea)
 {
     $persona_aplicativo = new aplicativo_ticket_persona();
     $persona_aplicativo->aplicativo_id = $id_ticket;
     $persona_aplicativo->ticket_persona_id = $idPersona;
     $persona_aplicativo->usucrea = $idUsuCrea;
     $persona_aplicativo->estado = '0';
     $persona_aplicativo->save();
     \Log::info('Se registro Correctamente el aplicativo en la cuenta...dao: aplicativo_ticket_persona/36.');
     return $persona_aplicativo->ticket_persona_id;
 }
Example #24
0
 public static function getHtml($url)
 {
     $client = new Client();
     $response = $client->get($url, ['verify' => false, 'timeout' => 10]);
     if ($response->getStatusCode() != 200) {
         $error = '%s: Bad HTTP response code, url is %s, status code is %d.';
         $error = sprintf($error, __METHOD__, $url, $response->getStatusCode());
         Log::error($error);
         throw new \Exception($error, 0);
     }
     return $response->getBody()->__toString();
 }
Example #25
0
 public function postListGridData(Request $req, $db = 'bidang')
 {
     /* paging biasa ======================================   select * from `dokumen` limit 0,10  */
     // if ($req->get('page')) {
     //     if ($req->get('page')==1) {
     //         $offset=$req->get('page')-1;
     //     }
     //     else{
     //          $offset=($req->get('page')-1)*$req->get('rows');
     //     }
     //     $data->skip($offset);
     // }
     // if ($req->get('rows')) {
     //     $data->take($req->get('rows'));
     // }
     // if ($req->get('sort') && $req->get('order')) {
     //     $data->orderBy($req->get('sort'), $req->get('order'));
     // }
     // $datax['rows']=$this->show_relasi_kolom($data->get());
     // $total['total'] = \DB::table('dokumen')->count();
     /**  ,=== snippet ===============================================================================
      */
     $offset = 1;
     if ($req->get('page')) {
         if ($req->get('page') == 1) {
             $offset = $req->get('page') - 1;
         } else {
             $offset = ($req->get('page') - 1) * $req->get('rows');
         }
     }
     $rows = 10;
     if ($req->get('rows')) {
         $rows = $req->get('rows');
     }
     // $log = Log::where('table','=',$db)->skip($page)->take($rows)->paginate();
     $log = Log::with('users', 'groups')->where('table', $db)->skip($offset)->take($rows)->paginate();
     // dd($rows);
     // dd($log->toArray());
     $newdata = [];
     $i = 0;
     foreach ($log->toArray()['data'] as $data) {
         $newdata[$i] = $data;
         $newdata[$i]['users_email'] = $data['users']['email'];
         $newdata[$i]['groups_name'] = $data['groups']['name'];
         $i++;
     }
     // $result['total']=$log->toArray()['total'];
     $result['total'] = count($log->toArray()['data']);
     // $result['rows']=$log->toArray()['data'];
     $result['rows'] = $newdata;
     return json_encode($result);
 }
Example #26
0
 public function process()
 {
     $transactionID = Input::get('transactionID');
     $transaction = Transaction::where('transaction_id', '=', $transactionID)->first();
     $logs = Log::where('transaction_id', '=', $transactionID)->get();
     $recentLog = Log::where('transaction_id', '=', $transactionID)->orderBy('created_at', 'desc')->first();
     if (Input::has('create')) {
         // Redirect to different route / URI
         return Redirect::route('superadmin/create_transaction')->with('transactionID', $transactionID);
         // Alternatively, you could process action 1 here
     } elseif (Input::has('update')) {
         // Process action 2
         return Redirect::route('superadmin/update_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('recentLog', $recentLog);
     } elseif (Input::has('out')) {
         // Process action 3
         return Redirect::route('superadmin/out_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('users', '')->with('recentLog', $recentLog);
     }
 }
 public function getDone(Request $request)
 {
     $id = $request->get('paymentId');
     $token = $request->get('token');
     $payer_id = $request->get('PayerID');
     $payment = PayPal::getById($id, $this->_apiContext);
     $paymentExecution = PayPal::PaymentExecution();
     $paymentExecution->setPayerId($payer_id);
     $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
     $order = Order::whereUserId(Auth::id())->orderBy('created_at', 'desc')->first();
     if (!is_null($order)) {
         $order->payment = $id;
         $order->save();
     }
     $log = Log::whereUserId(Auth::id())->whereReason('purchase')->orderBy('created_at', 'desc')->first();
     if (!is_null($log)) {
         $log->flag = true;
         $log->save();
     }
     return view('checkout.done');
 }
Example #28
0
 public function deletelog(Request $request)
 {
     $date = $request->input('date', date('Y-m-d H:i:s'));
     Log::dayBefore($date)->delete();
     echo json_encode("1");
 }
Example #29
0
 public function modifyPoints($points, $actionTypeId, $sourceId)
 {
     $data = ['action_type_id' => $actionTypeId, 'source_id' => $sourceId, 'details' => $points, 'user_id' => $this->id];
     $log = Log::create($data);
     $userPoints = new UserPoints();
     $userPoints->user_id = $this->id;
     $userPoints->action_type_id = $actionTypeId;
     $userPoints->source_id = $sourceId;
     $userPoints->points = $points;
     if ($userPoints->save()) {
         $this->current_points = $this->current_points + $points;
         //Action type = 9 is for canceled orders, the user should not add to accumulated points
         if ($points > 0 && $actionTypeId != 9) {
             $this->accumulated_points = $this->accumulated_points + $points;
         }
         if ($this->save()) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #30
0
 public function update(Request $request)
 {
     //dd($request->all());
     $niceNames = array('gradYear' => 'ปีจบการศึกษา', 'classRoom' => 'สายชั้น', 'CRNo' => 'เลขที่', 'studenNo' => 'รหัสนักเรียน', 'idCardNo' => 'รหัสประชาชน', 'titleName' => 'คำนำหน้าชื่อ', 'name' => 'ชื่อ', 'lastname' => 'นามสกุล', 'nickname' => 'ชื่อเล่น', 'birthday' => 'วันเกิด', 'address' => 'ที่อยู่', 'tel' => 'เบอร์โทรศัพท์');
     $messages = ['required' => ':attribute จำเป็นต้องระบุข้อมูล!', 'date_format' => 'รูปแบบวันที่ไม่ถูกต้อง! กรุณาระบุ ปีคศ-เดือน-วัน เท่านั้น!', 'email' => 'Email ไม่ถูกต้อง!', 'unique' => ':attribute มีผู้ใช้งานแล้ว!', 'alpha_num' => ':attribute กรุณาระบุตัวเลขหรือตัวอักษรเท่านั้น!', 'between' => ':attribute ต้องอยู่ระหว่าง :min ถึง :max ตัวอักษรเท่านั้น!', 'confirmed' => 'รหัสผ่านไม่ตรงกัน!', 'date_format' => ':attribute วันที่ไม่ถูกต้อง!', 'min' => ':attribute ข้อมูลต้องมี :max ตัว!', 'max' => ':attribute ข้อมูลต้องมี :max ตัว!'];
     $validator = Validator::make($request->all(), ['gradYear' => 'required', 'classRoom' => 'required', 'CRNo' => 'required', 'studenNo' => 'required', 'idCardNo' => 'required|max:13|min:13', 'titleName' => 'required', 'name' => 'required', 'lastname' => 'required', 'nickname' => 'required', 'address' => 'required', 'birthday' => 'required|date_format:Y-m-d', 'tel' => 'required'], $messages);
     $validator->setAttributeNames($niceNames);
     if ($validator->fails()) {
         return redirect(route('member', ['action' => '2']))->withErrors($validator->errors())->withInput($request->all());
     }
     $classRoom = explode(',', $request->get('classRoom'));
     //dd($classRoom);
     $memberUpdate = User::find(Auth::user()->id);
     $memberUpdate->gradYear = trim($request->get('gradYear'));
     $memberUpdate->class = trim($classRoom[0]);
     $memberUpdate->room = trim($classRoom[1]);
     $memberUpdate->CRNo = trim($request->get('CRNo'));
     $memberUpdate->studenNo = trim($request->get('studenNo'));
     $memberUpdate->idCardNo = trim($request->get('idCardNo'));
     $memberUpdate->titleName = trim($request->get('titleName'));
     $memberUpdate->name = trim($request->get('name'));
     $memberUpdate->lastname = trim($request->get('lastname'));
     $memberUpdate->nickname = trim($request->get('nickname'));
     $memberUpdate->birthday = trim($request->get('birthday'));
     $memberUpdate->address = trim($request->get('address'));
     $memberUpdate->tel = trim($request->get('tel'));
     $memberUpdate->contact = trim($request->get('contact'));
     $memberUpdate->save();
     $log = new Log();
     $log->memberId = Auth::user()->id;
     $log->detail = 'Update Member,' . $memberUpdate;
     $log->save();
     return redirect(route('member', ['action' => '2']));
 }