firstOrFail<T extends Model> method
Future
firstOrFail<T extends Model>({
- required String field,
- required dynamic value,
- String comp = "==",
- DatabaseDisk disk = Model.defaultDisk,
Retrieves the first model matching the given field/value pair or fails.
This method forwards to Model.firstOrFail and includes the current
request context.
Parameters:
field: The column or field name to query.value: The value to compare against.comp: The comparison operator. Presently forwarded by signature only.disk: The database disk to query.
Example:
final post = await request.firstOrFail<Post>(
field: 'slug',
value: 'welcome-to-archery',
);
Implementation
Future<dynamic> firstOrFail<T extends Model>({required String field, required dynamic value, String comp = "==", DatabaseDisk disk = Model.defaultDisk}) async {
return await Model.firstOrFail<T>(request: this, field: field, value: value, disk: disk);
}