On this page
InteractsWithDatabase
trait InteractsWithDatabase (View source)
Methods
| $this | assertDatabaseHas(Model|string $table, array $data, string|null $connection = null) Assert that a given where condition exists in the database. |
|
| $this | assertDatabaseMissing(Model|string $table, array $data, string|null $connection = null) Assert that a given where condition does not exist in the database. |
|
| $this | assertDatabaseCount(Model|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". |
|
| $this | assertNotSoftDeleted(Model|string $table, array $data = [], string|null $connection = null, string|null $deletedAtColumn = 'deleted_at') Assert the given record has not been "soft deleted". |
|
| $this | assertModelExists(Model $model) Assert the given model exists in the database. |
|
| $this | assertModelMissing(Model $model) Assert the given model does not exist in the database. |
|
| 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. |
|
| string | getTable(Model|string $table) Get the table name from the given model or string. |
|
| $this | seed(array|string $class = 'Database\\Seeders\\DatabaseSeeder') Seed a given database connection. |
Details
protected $this assertDatabaseHas(Model|string $table, array $data, string|null $connection = null)
Assert that a given where condition exists in the database.
protected $this assertDatabaseMissing(Model|string $table, array $data, string|null $connection = null)
Assert that a given where condition does not exist in the database.
protected $this assertDatabaseCount(Model|string $table, int $count, string|null $connection = null)
Assert the count of table entries.
protected $this assertDeleted(Model|string $table, array $data = [], string|null $connection = null)
Assert the given record has been deleted.
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".
protected $this assertNotSoftDeleted(Model|string $table, array $data = [], string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')
Assert the given record has not been "soft deleted".
protected $this assertModelExists(Model $model)
Assert the given model exists in the database.
protected $this assertModelMissing(Model $model)
Assert the given model does not exist in the database.
protected 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.
protected Connection getConnection(string|null $connection = null)
Get the database connection.
protected string getTable(Model|string $table)
Get the table name from the given model or string.
$this seed(array|string $class = 'Database\\Seeders\\DatabaseSeeder')
Seed a given database connection.
© 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