From 3d702630999f69632c9f23aef3b8b080d2a883fe Mon Sep 17 00:00:00 2001 From: Vaibhav Pandey Date: Tue, 21 Jun 2022 16:39:32 +0530 Subject: [PATCH] Fix blade to php generation. --- src/LockingServiceProvider.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/LockingServiceProvider.php b/src/LockingServiceProvider.php index fe16d7c..cf31a2c 100644 --- a/src/LockingServiceProvider.php +++ b/src/LockingServiceProvider.php @@ -35,18 +35,12 @@ public function register() */ public function boot() { - Blade::directive('lockInput', function (Model $model) { - $valid = in_array(LocksVersion::class, class_uses_recursive($model), true); - if (!$valid) { - throw new \RuntimeException( - sprintf('%s does not use %s trait.', get_class($model), LocksVersion::class) - ); - } - - /** @var LocksVersion $model */ - $fieldName = call_user_func(get_class($model), 'lockVersionColumnName'); - $fieldValue = $model->currentLockVersion(); - return sprintf('', $fieldName, $fieldValue); + Blade::directive('lockInput', function ($model) { + return sprintf( + '', + "call_user_func([get_class($model), 'lockVersionColumnName'])", + "{$model}->currentLockVersion()" + ); }); } }