/** * @before _secure, _vendor, _admin */ public function profile() { $this->seo(array("title" => "Vendor Profile", "view" => $this->getLayoutView())); $view = $this->getActionView(); $action = RequestMethods::post("action", ""); $account = Account::first(array("organization_id = ?" => $this->member->organization_id)); $org = $this->organization; switch ($action) { case 'tin': $org->tin = RequestMethods::post("tin"); $org->tin_file = $this->_upload("tin_file"); $org->save(); $view->set("message", "Saved Successfully"); break; case 'pan': $org->pan = RequestMethods::post("pan"); $org->pan_file = $this->_upload("pan_file"); $org->save(); $view->set("message", "Saved Successfully"); break; case 'lac': $org->lac = $this->_upload("lac"); $org->save(); $view->set("message", "Saved Successfully"); break; case 'termandcon': $org->terms = $this->_upload("terms"); $org->save(); $view->set("message", "Saved Successfully"); break; case 'authcerti': $org->terms = $this->_upload("certi"); $org->save(); $view->set("message", "Saved Successfully"); break; case 'user': $user = User::first(array("id = ?" => $this->user->id)); $user->name = RequestMethods::post("name"); $user->phone = RequestMethods::post("phone"); $user->save(); $view->set("user", $user); $view->set("message", "Saved Successfully"); break; case 'account': if (!$account) { $account = new Account(array("user_id" => $this->user->id, "organization_id" => $this->organization->id, "name" => RequestMethods::post("name"), "bank" => RequestMethods::post("bank"), "number" => RequestMethods::post("number"), "ifsc" => RequestMethods::post("ifsc", ""), "instamojo" => RequestMethods::post("instamojo", ""))); $account->save(); $view->set("message", "Saved Successfully"); } break; } $view->set("account", $account); }
/** * Test can't update primary key * * @return null */ public function testCantUpdatePKAttributes() { $account = TORM\Factory::create("account"); $this->assertTrue($account->save()); $account = Account::first(); $old_id = $account->id; $new_id = 999; $new_num = "54321"; $this->assertTrue($account->updateAttributes(array("id" => $new_id, "number" => $new_num))); $account = Account::find($old_id); $this->assertNotNull($account); $this->assertEquals($new_num, $account->number); $this->assertNull(Account::find($new_id)); }
public static function fromCredentials($user, $passHash) { return Account::first('username='******' AND password=' . safeSQLString($passHash)); }
public function testHasOneRelation() { $this->assertEquals(Account::first(), User::first()->account()); }
/** * Tests that credit account may be created. * * @return void */ public function testAccountCreateCredit() { $params = array('customer_id' => $this->user->id, 'balance' => 1000.32, 'type' => 'credit'); $response = $this->call('POST', '/account', $params); $account = Account::first(); $this->cleanUp(); $this->assertResponseStatus('201'); $this->assertEquals('credit', $account->type->name); }
public static function GetByName($accountName, $activatedOnly = false) { $account = Account::first(array('account_name' => $accountName, 'IsApproved' => $activatedOnly)); return $account; }
/** * Test has one relation * * @return null */ public function testHasOneRelation() { $account = Account::first(); $user = User::first(); $acct = $user->account; $this->assertNotNull($acct); $this->assertEquals("Account", get_class($acct)); $this->assertEquals($account->account_number, $acct->account_number); }