本文整理汇总了PHP中app\models\User::first方法的典型用法代码示例。如果您正苦于以下问题:PHP User::first方法的具体用法?PHP User::first怎么用?PHP User::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTheAppView
public function testTheAppView()
{
$this->artisan('db:seed');
$this->be(User::first());
$this->visit('/')->see('MyGains');
$this->assertViewHas(["exercises", "workouts"]);
}
示例2: register
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('App\\Settings', function () {
return User::first()->settings();
// return \Auth::user()->settings();
});
}
示例3: testFactory
public function testFactory()
{
factory(User::class, 50)->create();
$user = User::first();
$this->assertInstanceOf(User::class, $user);
$this->assertTrue($user->exists());
}
示例4: test
public function test($id)
{
$user = \App\Models\User::findHashed('47ee991c-8500-42e7-b6ba-50f6c1edb729');
$user->load('roles');
return $user;
return route('test', \App\Models\User::first());
return $id;
}
示例5: testDisplayCreateForm
public function testDisplayCreateForm()
{
echo "\n\nINSTRUMENT CONTROLLER TEST\n\n";
$url = URL::route('instrument.create');
// Set the current user to admin
$this->be(User::first());
$this->visit($url)->see('name');
}
示例6: testDelete
/**
* Testing Lot destroy funciton
*/
public function testDelete()
{
$this->be(User::first());
$this->runStore($this->input);
$lot = new LotController();
$lot->delete(1);
$lotDeleted = Lot::withTrashed()->find(1);
$this->assertNotNull($lotDeleted->deleted_at);
}
示例7: testDelete
/**
* Tests the update function in the SupplierController
* @depends testStore
* @param void
* @return void
*/
public function testDelete()
{
$this->be(User::first());
$this->runStore($this->input);
$supplier = new SupplierController();
$supplier->delete(1);
$supplierDeleted = Supplier::withTrashed()->find(1);
$this->assertNotNull($supplierDeleted->deleted_at);
}
示例8: seedAcl
private function seedAcl()
{
Bouncer::seeder(function () {
Bouncer::allow('admin')->to(['system.view', 'users.view', 'system.manage', 'users.manage']);
Bouncer::allow('manager')->to(['system.view', 'system.manage']);
Bouncer::allow('user')->to(['system.view']);
Bouncer::assign('admin')->to(User::first());
Bouncer::assign('manager')->to(User::where(['login' => 'manager'])->first());
});
}
示例9: testDelete
/**
* Tests the update function in the PatientController
* @depends testStore
* @param void
* @return void
*/
public function testDelete()
{
$this->be(User::first());
$this->runStore($this->input);
$patientSaved = Patient::orderBy('id', 'desc')->first();
$patient = new PatientController();
$patient->delete($patientSaved->id);
$patientsDeleted = Patient::withTrashed()->find($patientSaved->id);
$this->assertNotNull($patientsDeleted->deleted_at);
}
示例10: testStore
/**
* Tests the store function in the ChargeController
* @param void
* @return int $testChargeId ID of Charge stored;used in testUpdate() to identify test for update
*/
public function testStore()
{
echo "\n\nCHARGE CONTROLLER TEST\n\n";
// Store the Charge
$this->withoutMiddleware();
$this->be(User::first());
$this->call('POST', '/charge', $this->chargeData);
$chargeStored = Charge::orderBy('id', 'desc')->first();
$this->assertEquals($this->chargeData['test_id'], $chargeStored->test_id);
$this->assertEquals($this->chargeData['current_amount'], $chargeStored->current_amount);
}
示例11: test_passwords_delete
public function test_passwords_delete()
{
$this->test_access_after_setup();
$user = User::first();
$folder = PasswordFolder::where('user_id', $user->id)->first();
$password = factory(Password::class)->create(['folder_id' => $folder->id]);
$this->actingAs($password->folder->user);
$token = ['_token' => \Session::token()];
$this->delete(route('passwords.destroy', [$password->id]), $token);
$this->assertRedirectedToRoute('passwords.index');
}
示例12: testStore
/**
* Tests the store function in the PaymentController
* @param void
* @return int $testPaymentId ID of Payment stored;used in testUpdate() to identify test for update
*/
public function testStore()
{
echo "\n\nPAYMENT CONTROLLER TEST\n\n";
// Store the Payment
$this->withoutMiddleware();
$this->be(User::first());
$this->call('POST', '/payment', $this->paymentData);
$paymentStored = Payment::orderBy('id', 'desc')->first();
$this->assertEquals($this->paymentData['patient_id'], $paymentStored->patient_id);
$this->assertEquals($this->paymentData['charge_id'], $paymentStored->charge_id);
$this->assertEquals($this->paymentData['full_amount'], $paymentStored->full_amount);
$this->assertEquals($this->paymentData['amount_paid'], $paymentStored->amount_paid);
}
示例13: testStore
/**
* Tests the store function in the DrugController
* @param void
* @return int $testDrugId ID of Drug stored;used in testUpdate() to identify test for update
*/
public function testStore()
{
echo "\n\nDRUG CONTROLLER TEST\n\n";
// Store the Drug
$this->withoutMiddleware();
$this->be(User::first());
$response = $this->call('POST', '/drug', $this->drugData);
// dd($response);
$drugStored = Drug::orderBy('id', 'desc')->take(1)->get()->first();
// dd($drugStored);
// $drugSaved = Drug::find($drugStored->id);
$this->assertEquals($this->drugData['name'], $drugStored->name);
$this->assertEquals($this->drugData['description'], $drugStored->description);
}
示例14: form
public function form($form)
{
$class = 'app\\forms\\' . $form;
$form = new $class($this, array('user' => models\User::first('1 ORDER BY RAND()'), 'domain' => models\Domain::first('1 ORDER BY RAND()')));
$content = '';
if ($this->POST) {
$content .= '<pre>VALIDATION: ' . ($form->validate($_POST) ? 'OK' : 'FAIL') . '</pre>';
$content .= '<pre>' . print_r($form->errors(), 1) . '</pre>';
}
$content .= $form->render();
$content .= '<pre>$_POST: ' . print_r($_POST, 1) . '</pre>';
$content .= '<pre>&output: ' . print_r($form->output, 1) . '</pre>';
$content .= '<pre>$form: ' . print_r($form, 1) . '</pre>';
return $this->tpl->display(false, array('content' => $content));
}
示例15: testProfileSendEmail
/**
* Checks that the message box sends an email
*
* (I believe Laravel has a feature for this, so an email is not actually sent)
*/
public function testProfileSendEmail()
{
$faker = Faker\Factory::create();
factory(App\Models\Profile::class, 'withAUser', 1)->create();
$user = App\Models\User::first();
$message = $faker->sentences(3);
$this->visit(route('profile.view', ['name' => $user->username]))->type($message, 'message')->submitForm('Send');
$mock = \Mockery::mock($this->app['mailer']->getSwiftMailer());
$this->app['mailer']->setSwiftMailer($mock);
$mock->shouldReceive('send')->withArgs([\Mockery::on(function ($message) {
$this->assertEquals(trans('profile.message_subject', ['from' => Auth::user()->username]), $message->getSubject());
$this->assertSame([$user->profile->email => null], $message->getTo());
$this->assertContains(trans('profile.message_body'), $message->getBody());
return true;
}), \Mockery::any()])->once();
}