Example #1
0
 public function isValid($data = null)
 {
     if (SessionFacade::has('auth')) {
         return true;
     }
     if (CookieFacade::has('auth')) {
         $user = Users::findByCookieAuth($this->getCookie());
         if (!$user) {
             return false;
         }
         FlashFacade::success('欢迎' . $user->name . '登录!你上次登录的时间是:' . $user->updated_at);
         //利用cookie实现登录
         EventFacade::fire('auth:login', $user, ['remember' => 'on']);
         return true;
     }
     return false;
 }
Example #2
0
 public function addWebFile($source_id, $type)
 {
     $parser = myParser::getParser($type, $source_id);
     //获取Parser
     //        dd($parser);
     $data = $parser->parseInfo();
     //抽取数据
     //        dd($data);
     /** @var myModel|FileableTrait $this */
     $this->save($parser->getDataForFile());
     //保存file对象
     $data['file_id'] = $this->id;
     //补充数据,添加file_id
     $model = myParser::getModelBySourceId($type);
     //获取模型
     $model->save($data);
     //保存模型数据
     EventFacade::fire('standards:addWebFile', $model);
     $this->saveFileable($model);
     //保存关联对象数据
     return $this;
 }
Example #3
0
 public function beforeSave()
 {
     EventFacade::fire('tags:updateTag', $this);
     return parent::beforeSave();
 }
Example #4
0
 public function logoutAction()
 {
     EventFacade::fire('auth:logout', $this);
     $this->redirectByRoute(['for' => 'login']);
 }
Example #5
0
 public function deleteSelectedFilesAction()
 {
     $data = $this->request->getPost();
     if (count($data['file_id'])) {
         $files = Files::query()->inWhere('id', $data['file_id'])->execute();
         $files->delete();
         EventFacade::fire('standards:deleteSelectedFiles', $files);
         return 'success';
     }
     return 'failed';
 }