本文整理汇总了PHP中app\models\Account类的典型用法代码示例。如果您正苦于以下问题:PHP Account类的具体用法?PHP Account怎么用?PHP Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Account类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: login
public function login(Request $request)
{
// dd(\Crypt::encrypt('[email protected]'));
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('/');
}
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:32,代码来源:AutoLoginController.php
示例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();
}
}
}
开发者ID:JennySwift,项目名称:budget,代码行数:11,代码来源:AccountSeeder.php
示例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());
}
开发者ID:JennySwift,项目名称:budget,代码行数:16,代码来源:AccountsDestroyTest.php
示例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同步完成。");
}
开发者ID:renyang9876,项目名称:viease,代码行数:17,代码来源:AllFanGroup.php
示例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);
}
}
开发者ID:JennySwift,项目名称:budget,代码行数:21,代码来源:AccountsController.php
示例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;
}
开发者ID:sirantho20,项目名称:watchdog,代码行数:12,代码来源:LoginForm.php
示例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');
}
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:25,代码来源:ChargeRenewalInvoices.php
示例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');
}
开发者ID:magicians,项目名称:invoiceninja,代码行数:28,代码来源:SendRenewalInvoices.php
示例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);
}
开发者ID:JennySwift,项目名称:budget,代码行数:33,代码来源:FavouriteTransactionsController.php
示例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)]);
}
开发者ID:jgyaipl,项目名称:invoice-ninja,代码行数:7,代码来源:UserTableSeeder.php
示例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;
}
开发者ID:kmrsfrnc,项目名称:bananapress,代码行数:12,代码来源:LoginForm.php
示例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);
}
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:13,代码来源:EventsTableSeeder.php
示例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]);
}
开发者ID:nafrente,项目名称:invoice-ninja,代码行数:8,代码来源:UserTableSeeder.php
示例14: showSetup
public function showSetup()
{
if (Utils::isNinja() || Utils::isDatabaseSetup() && Account::count() > 0) {
return Redirect::to('/');
}
$view = View::make('setup');
return Response::make($view);
}
开发者ID:ricoa,项目名称:invoice-ninja,代码行数:8,代码来源:AppController.php
示例15: isWhiteLabel
public static function isWhiteLabel()
{
if (Utils::isNinjaProd()) {
return false;
}
$account = \App\Models\Account::first();
return $account && $account->hasFeature(FEATURE_WHITE_LABEL);
}
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:8,代码来源:Utils.php
示例16: actionDelete
public function actionDelete($id)
{
Account::findOne($id)->delete();
$session = new Session();
$session->open();
$session->setFlash('message', 'Deleted.');
return $this->redirect(['index']);
}
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:8,代码来源:AccountController.php
示例17: validateCredentials
public function validateCredentials(UserContract $user, array $credentials)
{
$profile = $user instanceof Account ? $user : Account::find($user->getAuthIdentifier());
if ($profile && $profile->id == $user->getAuthIdentifier()) {
return static::PAMAuthenticate($profile->username, $credentials['password']);
}
return false;
}
开发者ID:SYpanel,项目名称:SYpanel,代码行数:8,代码来源:PAMUserProvider.php
示例18: run
/**
* 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);
}
}
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:14,代码来源:ConferenceTableSeeder.php
示例19: updateProPlanPaid
public function updateProPlanPaid($clientPublicId, $proPlanPaid)
{
$account = Account::whereId($clientPublicId)->first();
if (!$account) {
return;
}
$account->pro_plan_paid = $proPlanPaid;
$account->save();
}
开发者ID:magicians,项目名称:invoiceninja,代码行数:9,代码来源:NinjaRepository.php
示例20: it_can_update_an_existing_account
/**
* @test
* @return void
*/
public function it_can_update_an_existing_account()
{
$this->logInUser();
$account = Account::forCurrentUser()->first();
$response = $this->call('PUT', '/api/accounts/' . $account->id, ['name' => 'numbat']);
$content = json_decode($response->getContent(), true);
$this->checkAccountKeysExist($content);
$this->assertEquals('numbat', $content['name']);
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
开发者ID:JennySwift,项目名称:budget,代码行数:14,代码来源:AccountsUpdateTest.php
注:本文中的app\models\Account类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论