Exemplo n.º 1
0
 public function get($id, $elequent)
 {
     $cacheKey = self::CACHE . $id;
     if ($elequent) {
         return SystemUser::find($id);
     }
     $cachedData = \Cache::has($cacheKey);
     if (empty($cachedData)) {
         $systemUser = SystemUser::find($id);
         if (!empty($systemUser)) {
             $systemUser = $systemUser->toArray();
             if (!empty($systemUser['pic_path'])) {
                 $systemUser['profile_pic'] = env('STORAGE_URL') . 'user_images/' . $systemUser['pic_path'];
             } else {
                 $systemUser['profile_pic'] = '';
             }
             $systemUser['created_at_formatted'] = date('Y-m-d', strtotime($systemUser['created_at']));
             unset($systemUser['password']);
             unset($systemUser['code']);
             // Set data in cache
             \Cache::forever($cacheKey, $systemUser);
             return $systemUser;
         } else {
             return false;
         }
     } else {
         return \Cache::get($cacheKey);
     }
 }
 public function run()
 {
     DB::table('system_users')->delete();
     SystemUser::create(['first_name' => 'Jason', 'last_name' => 'Bourne', 'mobile' => '03363274033', 'email' => '*****@*****.**', 'password' => Hash::make('prova2016'), 'pic_path' => '', 'status' => 'active', 'code' => '']);
 }