InteractsWithDatabase

trait InteractsWithDatabase (View source)

Methods

$this assertDatabaseHas(string $table, array $data, string|null $connection = null)

Assert that a given where condition exists in the database.

$this assertDatabaseMissing(string $table, array $data, string|null $connection = null)

Assert that a given where condition does not exist in the database.

$this assertDatabaseCount(string $table, int $count, string|null $connection = null)

Assert the count of table entries.

$this assertDeleted(Model|string $table, array $data = [], string|null $connection = null)

Assert the given record has been deleted.

$this assertSoftDeleted(Model|string $table, array $data = [], string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has been "soft deleted".

bool isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

Expression castAsJson(array|string $value)

Cast a JSON string to a database compatible type.

Connection getConnection(string|null $connection = null)

Get the database connection.

$this seed(array|string $class = 'Database\\Seeders\\DatabaseSeeder')

Seed a given database connection.

Details

protected $this assertDatabaseHas(string $table, array $data, string|null $connection = null)

Assert that a given where condition exists in the database.

Parameters

string $table
array $data
string|null $connection

Return Value

$this

protected $this assertDatabaseMissing(string $table, array $data, string|null $connection = null)

Assert that a given where condition does not exist in the database.

Parameters

string $table
array $data
string|null $connection

Return Value

$this

protected $this assertDatabaseCount(string $table, int $count, string|null $connection = null)

Assert the count of table entries.

Parameters

string $table
int $count
string|null $connection

Return Value

$this

protected $this assertDeleted(Model|string $table, array $data = [], string|null $connection = null)

Assert the given record has been deleted.

Parameters

Model|string $table
array $data
string|null $connection

Return Value

$this

protected $this assertSoftDeleted(Model|string $table, array $data = [], string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has been "soft deleted".

Parameters

Model|string $table
array $data
string|null $connection
string|null $deletedAtColumn

Return Value

$this

protected bool isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

Parameters

mixed $model

Return Value

bool

Expression castAsJson(array|string $value)

Cast a JSON string to a database compatible type.

Parameters

array|string $value

Return Value

Expression

protected Connection getConnection(string|null $connection = null)

Get the database connection.

Parameters

string|null $connection

Return Value

Connection

$this seed(array|string $class = 'Database\\Seeders\\DatabaseSeeder')

Seed a given database connection.

Parameters

array|string $class

Return Value

$this

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.html