public function getColumnByAttribute($attribute, $model = null) { if (is_string($model)) { $model = new $model(); } if ($model === null) { $model = $this; } return $model->getTableSchema()->getColumn($attribute); }