|
|
@@ -167,6 +167,20 @@ abstract class Model {
|
|
|
return $object;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param ...$id_parts
|
|
|
+ * @return static
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static function require(...$id_parts): object {
|
|
|
+ $row = static::get(...$id_parts);
|
|
|
+ if(!$row) {
|
|
|
+ $name = ucwords(str_replace("_", " ", static::$table));
|
|
|
+ throw new RuntimeException(__("%s not found.", $name));
|
|
|
+ }
|
|
|
+ return $row;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return static[]
|
|
|
* @throws Exception
|