3333use ReflectionMethod ;
3434use Stringable ;
3535
36+ use function Illuminate \Support \enum_value ;
37+
3638abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToString, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, Stringable, UrlRoutable
3739{
3840 use Concerns \HasAttributes,
@@ -52,7 +54,7 @@ abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToSt
5254 /**
5355 * The connection name for the model.
5456 *
55- * @var string|null
57+ * @var \UnitEnum| string|null
5658 */
5759 protected $ connection ;
5860
@@ -717,7 +719,7 @@ public function newInstance($attributes = [], $exists = false)
717719 * Create a new model instance that is existing.
718720 *
719721 * @param array<string, mixed> $attributes
720- * @param string|null $connection
722+ * @param \UnitEnum| string|null $connection
721723 * @return static
722724 */
723725 public function newFromBuilder ($ attributes = [], $ connection = null )
@@ -726,7 +728,7 @@ public function newFromBuilder($attributes = [], $connection = null)
726728
727729 $ model ->setRawAttributes ((array ) $ attributes , true );
728730
729- $ model ->setConnection ($ connection ?: $ this ->getConnectionName ());
731+ $ model ->setConnection ($ connection ?? $ this ->getConnectionName ());
730732
731733 $ model ->fireModelEvent ('retrieved ' , false );
732734
@@ -736,7 +738,7 @@ public function newFromBuilder($attributes = [], $connection = null)
736738 /**
737739 * Begin querying the model on a given connection.
738740 *
739- * @param string|null $connection
741+ * @param \UnitEnum| string|null $connection
740742 * @return \Illuminate\Database\Eloquent\Builder<static>
741743 */
742744 public static function on ($ connection = null )
@@ -1951,13 +1953,13 @@ public function getConnection()
19511953 */
19521954 public function getConnectionName ()
19531955 {
1954- return $ this ->connection ;
1956+ return enum_value ( $ this ->connection ) ;
19551957 }
19561958
19571959 /**
19581960 * Set the connection associated with the model.
19591961 *
1960- * @param string|null $name
1962+ * @param \UnitEnum| string|null $name
19611963 * @return $this
19621964 */
19631965 public function setConnection ($ name )
@@ -1970,7 +1972,7 @@ public function setConnection($name)
19701972 /**
19711973 * Resolve a connection instance.
19721974 *
1973- * @param string|null $connection
1975+ * @param \UnitEnum| string|null $connection
19741976 * @return \Illuminate\Database\Connection
19751977 */
19761978 public static function resolveConnection ($ connection = null )
0 commit comments