Пример #1
0
 public function retrieveByCredentials(array $credentials)
 {
     if (static::PAMAuthenticate($credentials['username'], $credentials['password'])) {
         return Account::where('username', $credentials['username'])->get()->first();
     }
     return false;
 }
Пример #2
0
 /**
  *
  */
 public function run()
 {
     $this->faker = Faker::create();
     $users = User::all();
     $this->expenseMerchants = ['John Doe', 'Jane Doe', 'John Smith', 'Sally Woods', 'Fred'];
     $this->expenseMerchantsIndex = -1;
     foreach ($users as $user) {
         $this->accounts = Account::where('user_id', $user->id)->get();
         // Get budget ids for user
         $this->fixedBudgetIds = $user->fixedBudgets()->lists('id')->all();
         $this->flexBudgetIds = $user->flexBudgets()->lists('id')->all();
         $this->mixedBudgetIds = [$this->fixedBudgetIds[0], $this->flexBudgetIds[0]];
         $num = 1;
         if ($user->id === 2) {
             $num = 20;
         }
         // Create transactions without budgets
         $this->createIncomeTransactionsWithoutBudgets($user, $num);
         $this->createExpenseTransactionsWithoutBudgets($user, $num);
         $this->createTransferTransactions($user, $num);
         //Create transactions with budgets
         $this->createExpenseTransactionsWithBudgets($user, $num);
         $this->createIncomeTransactionsWithBudgets($user, $num);
     }
 }
Пример #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('events')->insert([['id' => '1', 'eventName' => 'PartyNight', 'date' => '2016-01-01', 'startTime' => '14:00:00', 'endTime' => '15:00:00', 'location' => 'Beijing', 'description' => 'A test Event 1.', 'capacity' => 123, 'conferenceID' => 1], ['id' => '2', 'eventName' => 'Speech', 'date' => '2017-01-01', 'startTime' => '12:00:00', 'endTime' => '12:30:00', 'location' => 'Mumbai', 'description' => 'A test Event 2.', 'capacity' => 123, 'conferenceID' => 1]]);
     $role = RoleCreate::AllEventRoles(1);
     Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
     $role = RoleCreate::AllEventRoles(2);
     Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
 }
Пример #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $conferences = [['id' => 1, 'conferenceName' => 'Foo', 'dateStart' => '2016-01-01', 'dateEnd' => '2016-02-01', 'location' => 'Earth', 'description' => 'A test conference.', 'hasTransportation' => true, 'hasAccommodations' => false], ['id' => 2, 'conferenceName' => 'Bar', 'dateStart' => '2016-02-03', 'dateEnd' => '2016-02-05', 'location' => 'Earth', 'description' => 'A test conference number 2.', 'hasTransportation' => true, 'hasAccommodations' => true]];
     foreach ($conferences as $conf) {
         $c = Conference::create($conf);
         $role = RoleCreate::AllConferenceRoles($c->id);
         Account::where('email', 'root@localhost')->get()->first()->attachRole($role);
     }
 }
 public function resetPassword(Request $request)
 {
     if (!$request->has('email')) {
         return response()->json(['message' => 'no_email_given'], 400);
     }
     $account = Account::where('email', $request->input('email'))->get()->first();
     if (!isset($account)) {
         return response()->json(['message' => 'account_not_found'], 400);
     }
     $this->dispatch(new ResetPassword($account));
     return ["message" => "email_pending"];
 }
 public function getCounts($userId)
 {
     $accounts = Account::where('referral_user_id', $userId)->get();
     $counts = ['free' => 0, 'pro' => 0, 'enterprise' => 0];
     foreach ($accounts as $account) {
         $counts['free']++;
         $plan = $account->getPlanDetails(false, false);
         if ($plan) {
             $counts['pro']++;
             if ($plan['plan'] == PLAN_ENTERPRISE) {
                 $counts['enterprise']++;
             }
         }
     }
     return $counts;
 }
Пример #7
0
 public function d3()
 {
     $message = '';
     if (Auth::user()->account->isPro()) {
         $account = Account::where('id', '=', Auth::user()->account->id)->with(['clients.invoices.invoice_items', 'clients.contacts'])->first();
         $account = $account->hideFieldsForViz();
         $clients = $account->clients->toJson();
     } elseif (isset($_ENV['DATA_VIZ_SAMPLE'])) {
         $clients = $_ENV['DATA_VIZ_SAMPLE'];
         $message = trans('texts.sample_data');
     } else {
         $clients = '[]';
     }
     $data = ['feature' => ACCOUNT_DATA_VISUALIZATIONS, 'clients' => $clients, 'message' => $message];
     return View::make('reports.d3', $data);
 }
Пример #8
0
 public function d3()
 {
     $message = '';
     $fileName = storage_path() . '/dataviz_sample.txt';
     if (Auth::user()->account->isPro()) {
         $account = Account::where('id', '=', Auth::user()->account->id)->with(['clients.invoices.invoice_items', 'clients.contacts'])->first();
         $account = $account->hideFieldsForViz();
         $clients = $account->clients->toJson();
     } elseif (file_exists($fileName)) {
         $clients = file_get_contents($fileName);
         $message = trans('texts.sample_data');
     } else {
         $clients = '[]';
     }
     $data = ['clients' => $clients, 'message' => $message];
     return View::make('reports.d3', $data);
 }
Пример #9
0
 /**
  * Register a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     //Check if the request has account and password
     $validator = Validator::make($request->all(), ['account' => 'required|max:16', 'password' => 'required|max:20']);
     //If it is lack of account and password
     if ($validator->fails()) {
         return response()->json(['status' => 404, 'message' => 'input error', 'data' => null]);
     }
     //Check if the account is existed
     try {
         $exist = Account::where('account', '=', $request->input('account'))->firstOrFail();
     } catch (ModelNotFoundException $e) {
         $account = $request->input('account');
         $password = $request->input('password');
         $name = $request->input('name', 'default_user');
         $gender = $request->input('gender', 'unknown');
         $nationality = $request->input('nationality', 'France');
         $city = $request->input('city', 'Villejuif');
         $address = $request->input('address', '');
         //$hobby = $request->input('hobby','');
         $nickName = $request->input('nickName', '');
         $birthday = $request->input('birthday', '');
         //store it to the database
         $Account = new Account();
         $Account->account = $account;
         $Account->password = $password;
         $Account->name = $name;
         $Account->nickName = $nickName;
         $Account->gender = $gender;
         $Account->address = $address;
         $Account->nationality = $nationality;
         $Account->city = $city;
         //$Account->hobby = $hobby;
         $Account->birthday = $birthday;
         $Account->save();
         return response()->json(['status' => 0, 'message' => 'ok', 'data' => $Account->id]);
     }
     return response()->json(['status' => 403, 'message' => 'account existed', 'data' => null]);
 }
 /**
  *
  */
 public function run()
 {
     $users = User::all();
     foreach ($users as $user) {
         foreach ($this->favourites as $favourite) {
             $newFavourite = new FavouriteTransaction(['name' => $favourite['name'], 'type' => $favourite['type'], 'description' => $favourite['description'], 'merchant' => $favourite['merchant'], 'total' => $favourite['total']]);
             $newFavourite->user()->associate($user);
             if ($favourite['type'] === 'transfer') {
                 $newFavourite->fromAccount()->associate(Account::where('user_id', $user->id)->where('name', $favourite['fromAccount'])->first());
                 $newFavourite->toAccount()->associate(Account::where('user_id', $user->id)->where('name', $favourite['toAccount'])->first());
             } else {
                 $newFavourite->account()->associate(Account::where('user_id', $user->id)->where('name', $favourite['account'])->first());
             }
             $newFavourite->save();
             $budgetIds = [];
             foreach ($favourite['budgets'] as $budgetName) {
                 $budgetIds[] = Budget::where('user_id', $user->id)->where('name', $budgetName)->pluck('id');
             }
             $newFavourite->budgets()->attach($budgetIds);
         }
     }
 }
Пример #11
0
 public function checkEmail(Request $request)
 {
     $account = Account::where('email', '=', $request->only('email'))->first();
     if ($account === null) {
         return response()->json(['taken' => false]);
     } else {
         return response()->json(['taken' => true]);
     }
 }
 /**
  * @param $accountKey
  * @param $gatewayId
  * @return \Illuminate\Http\JsonResponse
  */
 public function handlePaymentWebhook($accountKey, $gatewayId)
 {
     $gatewayId = intval($gatewayId);
     $account = Account::where('accounts.account_key', '=', $accountKey)->first();
     if (!$account) {
         return response()->json(['message' => 'Unknown account'], 404);
     }
     $accountGateway = $account->getGatewayConfig(intval($gatewayId));
     if (!$accountGateway) {
         return response()->json(['message' => 'Unknown gateway'], 404);
     }
     $paymentDriver = $accountGateway->paymentDriver();
     try {
         $result = $paymentDriver->handleWebHook(Input::all());
         return response()->json(['message' => $result]);
     } catch (Exception $exception) {
         Utils::logError($exception->getMessage(), 'PHP');
         return response()->json(['message' => $exception->getMessage()], 500);
     }
 }
Пример #13
0
 /**
  * 获取当前选择的Account.
  *
  * @return Account
  */
 public function getCurrent()
 {
     return AccountModel::where('id', Session::get('account_id'))->first();
 }
Пример #14
0
 /**
  * 根据tag获取公众号.
  *
  * @param string $tag tag
  *
  * @return Model
  */
 public function getByTag($tag)
 {
     return $this->model->where('tag', $tag)->first();
 }
Пример #15
0
 public function approvedDependents($accountID)
 {
     if (!Entrust::can(PermissionNames::ApproveUserRegistration()) && Auth::user()->id != $accountID) {
         return response()->json(["message" => "no_user_approval_access"]);
     }
     $account = Account::where('id', '=', $accountID)->first();
     if ($account === null) {
         return response()->json(['message' => 'account_not_found']);
     } else {
         $dependents = User::where('accountID', '=', $account->id)->where('approved', '=', true)->get();
         return response()->json(['message' => 'returned_approved_dependents', 'dependents' => $dependents]);
     }
 }
Пример #16
0
 public function setConfig($s)
 {
     switch ($this->configDrive) {
         case 'file':
             $this->storeConfig = Config::get('amazon-mws.store.' . $s);
             break;
         case 'database':
             $accountModel = \App\Models\Account::where('account_id', $s)->limit(1)->first();
             if (!$accountModel) {
                 throw new \Exception("{$s} Config Model does not exist or cannot be read!");
             }
             $accountTokenJson = $accountModel->token;
             if (!empty($accountTokenJson)) {
                 $accountTokenData = json_decode($accountTokenJson, true);
             } else {
                 //TODO 异常要重新定义
                 throw new \Exception("{$s} Account Token not exist");
             }
             $MERCHANT_ID = array_get($accountTokenData, 'MERCHANT_ID');
             $MARKETPLACE_ID = array_get($accountTokenData, 'MARKETPLACE_ID');
             $AWS_ACCESS_KEY_ID = array_get($accountTokenData, 'AWS_ACCESS_KEY_ID');
             $AWS_SECRET_ACCESS_KEY = array_get($accountTokenData, 'AWS_SECRET_ACCESS_KEY');
             $MWS_TOKEN = array_get($accountTokenData, 'MWS_TOKEN', $AWS_SECRET_ACCESS_KEY);
             $COUNTRY_CODE = $accountModel->country_code;
             $configData = ['merchantId' => $MERCHANT_ID, 'marketplaceId' => $MARKETPLACE_ID, 'keyId' => $AWS_ACCESS_KEY_ID, 'secretKey' => $AWS_SECRET_ACCESS_KEY, 'MWSAuthToken' => $MWS_TOKEN, 'countryCode' => $COUNTRY_CODE];
             $this->storeConfig = $configData;
             break;
     }
     $AMAZON_SERVICE_URL = Config::get('amazon-mws.DEFAULT_AMAZON_SERVICE_URL');
     $accountInfo = Config::get('amazon-mws.accountInfo');
     if (isset($accountInfo[$this->storeConfig['countryCode']])) {
         $AMAZON_SERVICE_URL = array_get($accountInfo[$this->storeConfig['countryCode']], 'SERVICE_URL');
     }
     if (isset($AMAZON_SERVICE_URL)) {
         $this->urlbase = $AMAZON_SERVICE_URL;
     } else {
         throw new \Exception("Config file does not exist or cannot be read!");
     }
 }