File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,32 @@ class BaseModel
72
72
* @var string
73
73
*/
74
74
protected $ connection = Connection::DEFAULT_NAME ;
75
+
76
+ /**
77
+ * Determine if an attribute or relation exists on the model.
78
+ * The __isset magic method is triggered by calling isset() or empty() on inaccessible properties.
79
+ *
80
+ * @param string $key The name of the attribute or relation.
81
+ * @return bool True if the attribute or relation exists, false otherwise.
82
+ */
83
+ public function __isset ($ key )
84
+ {
85
+ if (array_key_exists ($ key , $ this ->attributes )) {
86
+ return true ;
87
+ }
75
88
89
+ $ accessor = 'get ' . Str::studly ($ key ) . 'Attribute ' ;
90
+ if (method_exists ($ this , $ accessor )) {
91
+ return true ;
92
+ }
93
+
94
+ if (array_key_exists ($ key , $ this ->relations )) {
95
+ return true ;
96
+ }
97
+
98
+ return false ;
99
+ }
100
+
76
101
/**
77
102
* Get the table associated with the model.
78
103
*
You can’t perform that action at this time.
0 commit comments