Ejemplo n.º 1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $token = $request->get('token');
     if ($token) {
         $cacheTag = ['managers', 'auth'];
         $cacheKey = $token;
         $data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($request, $token) {
             $_manager = Managers::where('token', urldecode($token))->where('ip', $request->ip());
             if ($_manager->count() > 0) {
                 return $_manager->first()->toArray();
             } else {
                 return false;
             }
         });
         if ($data) {
             config(['global.token' => $token]);
             config(['global.managers.current.id' => $data['id']]);
             config(['global.managers.current.name' => $data['name']]);
             config(['global.managers.current.role' => $data['role']]);
             config(['global.managers.current.active' => $data['active']]);
         } else {
             Cache::tags($cacheTag)->forget($cacheKey);
         }
     }
     return $next($request);
 }
Ejemplo n.º 2
0
 public function create($request)
 {
     $validator = $this->validate($request);
     if (!$validator->fails()) {
         Managers::create(['name' => $request['name'], 'email' => $request['email'], 'password' => Hash::make($request['password'])]);
         Auth::sendNewManagerEmail($request['email']);
         return redirect()->away('http://' . config('global.origin.current') . $request['redirectonsuccess'] . '?message=Registro realizado com sucesso! Verifique seu email.');
     } else {
         return redirect()->away('http://' . config('global.origin.current') . $request['redirectonerror'] . '?message=' . $validator->errors()->first());
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Managers::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date' => $this->date, 'clubID' => $this->clubID]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'fullName', $this->fullName]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 public function store($request)
 {
     $cacheTag = ['companies'];
     $validator = $this->validate($request);
     if (!$validator->fails()) {
         Logs::create(['activity' => 'store', 'module' => 'companies']);
         Cache::tags($cacheTag)->flush();
         $_model = Managers::find(config('global.managers.current.id'));
         $_company = $_model->companies()->create($request);
         Configurations::create(['company_id' => $_company->id]);
         Processes::create(['company_id' => $_company->id, 'description' => 'Pedido realizado', 'order' => 1, 'color' => '#444444']);
         $_company->token = config('global.managers.current.id') . uniqid();
         return $_company->update();
     } else {
         return new \Exception($validator->errors()->first());
     }
 }
Ejemplo n.º 5
0
 public static function isManager($id)
 {
     if (config('global.managers.current.role') === 'S') {
         return true;
     } else {
         $cacheTag = ['companies', 'ismanager', $id];
         $cacheKey = config('global.managers.current.id');
         $response = Cache::tags($cacheTag)->remember($cacheKey, 60 * 24 * 7, function () use($id) {
             $_model = Managers::find(config('global.managers.current.id'));
             return $_model->companies()->select(['id'])->where('company_id', $id)->count();
         });
         if ($response > 0) {
             return true;
         } else {
             return false;
         }
     }
 }
 public function reset($request)
 {
     if (!empty($request) && $request['email']) {
         $_manager = Managers::where('email', $request['email']);
         if ($_manager->count() > 0) {
             $hash = md5(Hash::make($request['email']));
             if ($_manager->update(['recovercode' => $hash])) {
                 Auth::sendRecoverEmail($hash, $request['email']);
                 return true;
             } else {
                 return new \Exception('<b>Err...</b> Tivemos um problema para iniciar o processo de redefinição de senha. Tente novamente mais tarde.');
             }
         } else {
             return new \Exception('<b>Estranho...</b> O email digitado não aparece em nosso banco de dados ;/');
         }
     } else {
         return new \Exception('Você precisa digitar um email');
     }
 }
Ejemplo n.º 7
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $token = config('global.token');
     if (!empty($token)) {
         $cacheTag = ['managers', 'auth'];
         $cacheKey = $token;
         $data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($token) {
             $_manager = Managers::where('token', $token)->where('ip', $request->ip());
             if ($_manager->count() > 0) {
                 return $_manager->first()->toArray();
             } else {
                 return false;
             }
         });
         if ($data) {
             return $next($request);
         } else {
             return response()->json(["status" => 'fatal-error', "data" => [], "message" => 'Você não tem permissão para acessar este módulo (token not found).']);
         }
     } else {
         return response()->json(["status" => 'fatal-error', "data" => [], "message" => 'Você não tem permissão para acessar este módulo (empty token).']);
     }
 }
Ejemplo n.º 8
0
 public function store($companyId, $request)
 {
     $cacheTag = ['companies', 'company' . $companyId, 'managers'];
     $cacheKey = 'index';
     $_companies = Companies::find($companyId);
     if ($_companies) {
         $_manager = Managers::where('email', '=', $request['email']);
         if ($_manager->count() > 0) {
             $_company_manager = $_companies->managers()->where('email', '=', $request['email']);
             if ($_company_manager->count() === 0) {
                 Cache::tags($cacheTag)->flush();
                 Logs::create(['activity' => 'store', 'module' => 'companies_managers', 'ref' => $request['email']]);
                 return $_companies->managers()->attach($_manager->select(['id'])->first()->id);
             } else {
                 return new \Exception("O usuário que você está tentando adicionar já é administrador desta empresa");
             }
         } else {
             return new \Exception("<b>Que estranho...</b> Parece que esse email não está cadastrado em nosso sistema.");
         }
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
Ejemplo n.º 9
0
 public function destroy($id)
 {
     $cacheTag = ['managers'];
     $_model = Managers::find($id);
     if ($_model) {
         Logs::create(['activity' => 'destroy', 'module' => 'profile']);
         Cache::tags($cacheTag)->flush();
         return $_model->delete();
     } else {
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
 }
Ejemplo n.º 10
0
Archivo: Order.php Proyecto: arsik/xfit
 public static function getManagersList()
 {
     // Выбираем только те категории, у которых есть дочерние категории
     $parents = Managers::find()->select(['id', 'username'])->all();
     return ArrayHelper::map($parents, 'id', 'username');
 }
Ejemplo n.º 11
0
 public function image($request)
 {
     if (!empty($request->manager_id)) {
         $_model = Managers::find($request->manager_id);
         if ($request->hasFile('file')) {
             $_file = $request->file('file');
             if ($_model->avatar) {
                 Storage::delete($_model->avatar);
             }
             $filename = md5(time() . $_file->getClientOriginalName() . $request->manager_id) . '.' . $_file->guessClientExtension();
             $request->file('file')->move(config('filesystems.disks.local.root'), $filename);
             $_model->avatar = $filename;
             $_model->save();
             Logs::create(['activity' => 'avatar', 'module' => 'managers']);
             Cache::tags(['managers'])->flush();
             return true;
         } else {
             return new \Exception("Parece que você não selecionou nenhum arquivo");
         }
     } else {
         return new \Exception("Administrador não encontrado.");
     }
 }
Ejemplo n.º 12
0
 /**
  * Finds the Managers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Managers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Managers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\Models\Managers::create(['name' => 'Pingado Web', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'active' => true, 'role' => 'S']);
 }
Ejemplo n.º 14
0
Archivo: _form.php Proyecto: arsik/xfit
<div class="order-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
$clubs = \app\models\Clubs::find()->all();
$items = ArrayHelper::map($clubs, 'id', 'name');
$params = ['prompt' => 'Выберите клуб'];
echo $form->field($model, 'clubID')->dropDownList($items, $params);
?>

    <?php 
$managers = \app\models\Managers::find()->all();
$items = ArrayHelper::map($managers, 'id', 'username');
$params = ['prompt' => 'Выберите менеджера'];
echo $form->field($model, 'managerID')->dropDownList($items, $params);
?>

    <?php 
//$form->field($model, 'deliveryTime')->textInput()
?>

    <?php 
//$form->field($model, 'createTime')->textInput()
?>

    <?php 
//$form->field($model, 'session')->textInput(['maxlength' => true])
Ejemplo n.º 15
0
Archivo: index.php Proyecto: arsik/xfit
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\SearchManagers */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Менеджеры';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="managers-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Добавить менеджера', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'username', 'date', ['attribute' => 'clubID', 'label' => 'Клуб', 'format' => 'text', 'content' => function ($data) {
    return $data->getClubsName();
}, 'filter' => \app\models\Managers::getClubsList()], 'fullName', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Ejemplo n.º 16
0
Archivo: Orders.php Proyecto: fijj/map
 function getManagers()
 {
     return $this->hasOne(Managers::className(), ['id' => 'managerId']);
 }
Ejemplo n.º 17
0
Archivo: main.php Proyecto: arsik/xfit
?>
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<?php 
$managers = \app\models\Managers::find()->count() - 1;
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'XFIT', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Войти', 'url' => ['/site/login']];
} else {
    $menuItems = [['label' => 'Главная', 'url' => ['/site/index']], ['label' => 'Менеджеры (' . $managers . ')', 'url' => ['/managers']]];
    $menuItems[] = ['label' => 'Выйти (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
Ejemplo n.º 18
0
 public function actionContact()
 {
     return $this->render('contact', ['managers' => Managers::find()->all()]);
 }