当前位置: 首页>>代码示例>>PHP>>正文


PHP Person::username方法代码示例

本文整理汇总了PHP中app\models\Person::username方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::username方法的具体用法?PHP Person::username怎么用?PHP Person::username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Person的用法示例。


在下文中一共展示了Person::username方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store logs
  *
  * 1. Check input
  * 2. Check auth
  * 3. Check tracker version
  * 4. Check data log
  * 5. Simpan data log
  * @return Response
  */
 public function store()
 {
     dd(Response::json('101', 200));
     $attributes = Input::only('application', 'log');
     //1. Check input
     if (!$attributes['application']) {
         return Response::json('101', 200);
     }
     if (!isset($attributes['application']['api']['client']) || !isset($attributes['application']['api']['secret']) || !isset($attributes['application']['api']['station_id'])) {
         return Response::json('102', 200);
     }
     //2. Check auth
     $results = \App\Models\Api::client($attributes['application']['api']['client'])->secret($attributes['application']['api']['secret'])->workstationaddress($attributes['application']['api']['station_id'])->with(['branch'])->first();
     if (!$results) {
         $filename = storage_path() . '/logs/appid.log';
         $fh = fopen($filename, 'a+');
         $template = date('Y-m-d H:i:s : Log : ') . json_encode($attributes['application']['api']) . "\n";
         fwrite($fh, $template);
         fclose($fh);
         return Response::json('402', 200);
     }
     //3. Check tracker version
     if (isset($attributes['application']['api']['tr_ver']) && strtolower($attributes['application']['api']['tr_ver']) != $result['tr_version']) {
         $result->tr_version = strtolower($attributes['application']['api']['tr_ver']);
         if (!$result->save()) {
             return Response::json('301', 200);
         }
     }
     $organisationid = $result->branch->organisation_id;
     //4. Check data log
     if (!$attributes['log']) {
         return Response::json('103', 200);
     }
     //5. Simpan data log
     DB::beginTransaction();
     if (isset($attributes['log'])) {
         $attributes['log'] = (array) $attributes['log'];
         foreach ($attributes['log'] as $key => $value) {
             $log['name'] = strtolower($value[1]);
             $log['on'] = date("Y-m-d H:i:s", strtotime($value[2]));
             $log['pc'] = $value[3];
             $person = \App\Models\Person::username($value[0])->first();
             //5a. check is log belongs to existed user
             if (!$person) {
                 //5b. store log to error if not
                 $log['email'] = $value[0];
                 $log['message'] = 'User tidak terdaftar';
                 $log['organisation_id'] = $organisationid;
                 $log['ip'] = $_SERVER['REMOTE_ADDR'];
                 $saved_error_log = new \App\Models\ErrorLog();
                 $saved_error_log->fill($log);
                 $saved_error_log->save();
             } else {
                 //5b. store log to log if yes
                 $log['person_id'] = $person['id'];
                 $saved_log = new \App\Models\Log();
                 $saved_log->fill($log);
                 if (!$saved_log->save()) {
                     $log['email'] = $value[0];
                     $log['message'] = json_encode($saved_log->getError());
                     $log['ip'] = $_SERVER['REMOTE_ADDR'];
                     $saved_error_log = new \App\Models\ErrorLog();
                     $saved_error_log->fill($log);
                     $saved_error_log->save();
                 }
             }
         }
     }
     DB::commit();
     return Response::json('Sukses', 200);
 }
开发者ID:ThunderID,项目名称:HRIS-API,代码行数:81,代码来源:LogV0Controller.php


注:本文中的app\models\Person::username方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。