本文整理汇总了PHP中app\models\Account类的典型用法代码示例。如果您正苦于以下问题:PHP Account类的具体用法?PHP Account怎么用?PHP Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login(Request $request)
{
// dd(\Crypt::encrypt('jtmccombs@gmail.com'));
try {
$email = \Crypt::decrypt($request->get('token'));
} catch (\Exception $e) {
return abort('403', 'Forbidden');
}
$user = User::whereEmail($email)->first();
if (!$user) {
return abort('403', 'Forbidden');
}
if (!$user->account) {
$b2bCompany = \DB::connection('mysql-b2b')->table('companies')->where('user_id', '=', $user->id)->first();
// $b2bCompany = false;
$accountName = $b2bCompany ? $b2bCompany->company_name : $user->email;
$account = new Account();
$account->ip = $request->getClientIp();
$account->name = $accountName;
$account->account_key = str_random(RANDOM_KEY_LENGTH);
$account->save();
$user->account_id = $account->id;
$user->registered = true;
$user->save();
$exists = \DB::connection('mysql')->table('users')->whereId($user->id)->count();
if (!$exists) {
\DB::connection('mysql')->table('users')->insert(['id' => $user->id, 'account_id' => $user->account_id, 'created_at' => $user->created_at, 'updated_at' => $user->updated_at, 'deleted_at' => $user->deleted_at, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'phone' => $user->phone, 'username' => $user->username, 'email' => $user->email, 'password' => $user->password, 'confirmation_code' => $user->confirmation_code, 'registered' => $user->registered, 'confirmed' => $user->confirmed, 'notify_sent' => $user->notify_sent, 'notify_viewed' => $user->notify_viewed, 'notify_paid' => $user->notify_paid, 'public_id' => $user->public_id, 'force_pdfjs' => false, 'remember_token' => $user->remember_token, 'news_feed_id' => $user->news_feed_id, 'notify_approved' => $user->notify_approved, 'failed_logins' => $user->failed_logins, 'dark_mode' => $user->dark_mode, 'referral_code' => $user->referral_code]);
}
}
\Auth::loginUsingId($user->id);
return redirect('/');
}
示例2: run
public function run()
{
$users = User::all();
foreach ($users as $user) {
foreach ($this->accounts as $account) {
$tmp = new Account(['name' => $account]);
$tmp->user()->associate($user);
$tmp->save();
}
}
}
示例3: it_can_delete_an_account
/**
* @test
* @return void
*/
public function it_can_delete_an_account()
{
$this->logInUser();
$name = 'echidna';
$account = new Account(compact('name'));
$account->user()->associate($this->user);
$account->save();
$response = $this->call('DELETE', '/api/accounts/' . $account->id);
$this->assertEquals(204, $response->getStatusCode());
$response = $this->call('DELETE', '/api/account/' . $account->id);
$this->assertEquals(404, $response->getStatusCode());
}
示例4: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$accountModel = new Account();
$accounts = $accountModel->get();
$this->output->progressStart($accounts->count());
foreach ($accounts as $account) {
$this->call('sync:groups', array('account_id' => $account->id));
$this->output->progressAdvance();
}
$this->output->progressFinish();
$this->info("\n同步完成。");
}
示例5: destroy
/**
* DELETE /api/accounts/{accounts}
* @param DeleteAccountRequest $deleteAccountRequest
* @param Account $account
* @return Response
*/
public function destroy(DeleteAccountRequest $deleteAccountRequest, Account $account)
{
try {
$account->delete();
return response([], Response::HTTP_NO_CONTENT);
} catch (\Exception $e) {
//Integrity constraint violation
if ($e->getCode() === '23000') {
$message = 'Account could not be deleted. It is in use.';
} else {
$message = 'There was an error';
}
return response(['error' => $message, 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
}
}
示例6: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = Account::findByUsername($this->username);
}
return $this->_user;
}
示例7: fire
public function fire()
{
$this->info(date('Y-m-d') . ' ChargeRenewalInvoices...');
$ninjaAccount = $this->accountRepo->getNinjaAccount();
$invoices = Invoice::whereAccountId($ninjaAccount->id)->whereDueDate(date('Y-m-d'))->where('balance', '>', 0)->with('client')->orderBy('id')->get();
$this->info(count($invoices) . ' invoices found');
foreach ($invoices as $invoice) {
// check if account has switched to free since the invoice was created
$account = Account::find($invoice->client->public_id);
if (!$account) {
continue;
}
$company = $account->company;
if (!$company->plan || $company->plan == PLAN_FREE) {
continue;
}
try {
$this->info("Charging invoice {$invoice->invoice_number}");
$this->paymentService->autoBillInvoice($invoice);
} catch (Exception $exception) {
$this->info('Error: ' . $exception->getMessage());
}
}
$this->info('Done');
}
示例8: fire
public function fire()
{
$this->info(date('Y-m-d') . ' Running SendRenewalInvoices...');
$today = new DateTime();
$sentTo = [];
// get all accounts with pro plans expiring in 10 days
$accounts = Account::whereRaw('datediff(curdate(), pro_plan_paid) = 355')->orderBy('id')->get();
$this->info(count($accounts) . ' accounts found');
foreach ($accounts as $account) {
// don't send multiple invoices to multi-company users
if ($userAccountId = $this->accountRepo->getUserAccountId($account)) {
if (isset($sentTo[$userAccountId])) {
continue;
} else {
$sentTo[$userAccountId] = true;
}
}
$client = $this->accountRepo->getNinjaClient($account);
$invitation = $this->accountRepo->createNinjaInvoice($client);
// set the due date to 10 days from now
$invoice = $invitation->invoice;
$invoice->due_date = date('Y-m-d', strtotime('+ 10 days'));
$invoice->save();
$this->mailer->sendInvoice($invoice);
$this->info("Sent invoice to {$client->getDisplayName()}");
}
$this->info('Done');
}
示例9: update
/**
* UPDATE /api/favouritesTransactions/{favouriteTransactions}
* @param Request $request
* @param FavouriteTransaction $favourite
* @return Response
*/
public function update(Request $request, FavouriteTransaction $favourite)
{
// Create an array with the new fields merged
$data = array_compare($favourite->toArray(), $request->only(['name', 'type', 'description', 'merchant', 'total']));
$favourite->update($data);
if ($request->has('account_id')) {
$favourite->account()->associate(Account::findOrFail($request->get('account_id')));
$favourite->fromAccount()->dissociate();
$favourite->toAccount()->dissociate();
$favourite->save();
}
if ($request->has('from_account_id')) {
$favourite->fromAccount()->associate(Account::findOrFail($request->get('from_account_id')));
$favourite->account()->dissociate();
$favourite->save();
}
if ($request->has('to_account_id')) {
$favourite->toAccount()->associate(Account::findOrFail($request->get('to_account_id')));
$favourite->account()->dissociate();
$favourite->save();
}
if ($request->has('budget_ids')) {
$favourite->budgets()->sync($request->get('budget_ids'));
}
$favourite = $this->transform($this->createItem($favourite, new FavouriteTransactionTransformer()))['data'];
return response($favourite, Response::HTTP_OK);
}
示例10: run
public function run()
{
$this->command->info('Running UserTableSeeder');
Eloquent::unguard();
$account = Account::create(['name' => 'Test Account', 'account_key' => str_random(16), 'timezone_id' => 1]);
User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD)]);
}
示例11: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = Account::findOne(['email' => $this->username]);
}
return $this->_user;
}
示例12: run
/**
* 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);
}
示例13: run
public function run()
{
$this->command->info('Running UserTableSeeder');
Eloquent::unguard();
$account = Account::create(['name' => 'Test Account', 'account_key' => str_random(16), 'timezone_id' => 1]);
User::create(['email' => TEST_USERNAME, 'username' => TEST_USERNAME, 'account_id' => $account->id, 'password' => Hash::make(TEST_PASSWORD), 'registered' => true, 'confirmed' => true]);
Affiliate::create(['affiliate_key' => SELF_HOST_AFFILIATE_KEY]);
}
示例14: showSetup
public function showSetup()
{
if (Utils::isNinja() || Utils::isDatabaseSetup() && Account::count() > 0) {
return Redirect::to('/');
}
$view = View::make('setup');
return Response::make($view);
}
示例15: isWhiteLabel
public static function isWhiteLabel()
{
if (Utils::isNinjaProd()) {
return false;
}
$account = \App\Models\Account::first();
return $account && $account->hasFeature(FEATURE_WHITE_LABEL);
}