From 6899c2cb5ab784e6ee1ebd46397c98df0a18e905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20S=C3=A1nchez=20Palma?= <40817962+JA-Developer@users.noreply.github.com> Date: Mon, 24 Mar 2025 06:24:12 -0600 Subject: [PATCH 1/3] Fixed error "method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given" when using Livewire and AdminLTE. (#524) * Fixed error 'method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given' when using Darryldecode\Cart\Cart. * Check if the $event variable is an object before checking if it was dispatched by NativePHP. --- src/Events/EventWatcher.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Events/EventWatcher.php b/src/Events/EventWatcher.php index bae9ae7d..8163e1a6 100644 --- a/src/Events/EventWatcher.php +++ b/src/Events/EventWatcher.php @@ -14,6 +14,10 @@ public function register(): void Event::listen('*', function (string $eventName, array $data) { $event = $data[0] ?? (object) null; + if(! is_object($event)) { + return; + } + if (! method_exists($event, 'broadcastOn')) { return; } From 5992b012af721d3fb48cfdcc105753c123a1b012 Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Tue, 25 Mar 2025 06:56:45 +0100 Subject: [PATCH 2/3] feat: implement Alert class and facade for alert management (#523) * feat: implement Alert class and facade for alert management * refactor: remove unused methods from Alert class --- src/Alert.php | 94 +++++++++++++++++++++++++++++++++++++++++++ src/Facades/Alert.php | 23 +++++++++++ 2 files changed, 117 insertions(+) create mode 100644 src/Alert.php create mode 100644 src/Facades/Alert.php diff --git a/src/Alert.php b/src/Alert.php new file mode 100644 index 00000000..4ddcb8f5 --- /dev/null +++ b/src/Alert.php @@ -0,0 +1,94 @@ +type = $type; + + return $this; + } + + public function title(string $title): self + { + $this->title = $title; + + return $this; + } + + public function detail(string $detail): self + { + $this->detail = $detail; + + return $this; + } + + public function buttons(array $buttons): self + { + $this->buttons = $buttons; + + return $this; + } + + public function defaultId(int $defaultId): self + { + $this->defaultId = $defaultId; + + return $this; + } + + public function cancelId(int $cancelId): self + { + $this->cancelId = $cancelId; + + return $this; + } + + public function show(string $message): int + { + $response = $this->client->post('alert/message', [ + 'message' => $message, + 'type' => $this->type, + 'title' => $this->title, + 'detail' => $this->detail, + 'buttons' => $this->buttons, + 'defaultId' => $this->defaultId, + 'cancelId' => $this->cancelId + ]); + + return (int) $response->json('result'); + } + + public function error(string $title, string $message): bool + { + $response = $this->client->post('alert/error', [ + 'title' => $title, + 'message' => $message, + ]); + + return (bool) $response->json('result'); + } +} diff --git a/src/Facades/Alert.php b/src/Facades/Alert.php new file mode 100644 index 00000000..a4b151fa --- /dev/null +++ b/src/Facades/Alert.php @@ -0,0 +1,23 @@ + Date: Thu, 27 Mar 2025 16:57:44 +0000 Subject: [PATCH 3/3] Environment Helper (#527) * Add Environment Class with OS Helpers * Abstract all usages of PHP_OS_FAMILY to Environment class * Fix styling --------- Co-authored-by: Pete Bishop --- src/Alert.php | 14 +++++++------- src/Commands/DebugCommand.php | 7 ++++--- src/Events/EventWatcher.php | 2 +- src/Support/Environment.php | 31 +++++++++++++++++++++++++++++++ src/System.php | 3 ++- 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/Support/Environment.php diff --git a/src/Alert.php b/src/Alert.php index 4ddcb8f5..d00e7eff 100644 --- a/src/Alert.php +++ b/src/Alert.php @@ -2,23 +2,23 @@ namespace Native\Laravel; -use Illuminate\Support\Traits\Conditionable; -use Illuminate\Support\Traits\Macroable; use Native\Laravel\Client\Client; -use Native\Laravel\Facades\Window; class Alert { protected ?string $type; + protected ?string $title; + protected ?string $detail; + protected ?array $buttons; + protected ?int $defaultId; + protected ?int $cancelId; - final public function __construct(protected Client $client) - { - } + final public function __construct(protected Client $client) {} public static function new() { @@ -76,7 +76,7 @@ public function show(string $message): int 'detail' => $this->detail, 'buttons' => $this->buttons, 'defaultId' => $this->defaultId, - 'cancelId' => $this->cancelId + 'cancelId' => $this->cancelId, ]); return (int) $response->json('result'); diff --git a/src/Commands/DebugCommand.php b/src/Commands/DebugCommand.php index 3900d3c7..ad79c3b6 100644 --- a/src/Commands/DebugCommand.php +++ b/src/Commands/DebugCommand.php @@ -8,6 +8,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Process; +use Native\Laravel\Support\Environment; use function Laravel\Prompts\error; use function Laravel\Prompts\info; @@ -53,7 +54,7 @@ private function processEnvironment(): static { $locationCommand = 'which'; - if (PHP_OS_FAMILY === 'Windows') { + if (Environment::isWindows()) { $locationCommand = 'where'; } @@ -154,9 +155,9 @@ private function outputToClipboard(): void $json = json_encode($this->debugInfo->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); // Copy json to clipboard - if (PHP_OS_FAMILY === 'Windows') { + if (Environment::isWindows()) { Process::run('echo '.escapeshellarg($json).' | clip'); - } elseif (PHP_OS_FAMILY === 'Linux') { + } elseif (Environment::isLinux()) { Process::run('echo '.escapeshellarg($json).' | xclip -selection clipboard'); } else { Process::run('echo '.escapeshellarg($json).' | pbcopy'); diff --git a/src/Events/EventWatcher.php b/src/Events/EventWatcher.php index 8163e1a6..6df7e248 100644 --- a/src/Events/EventWatcher.php +++ b/src/Events/EventWatcher.php @@ -14,7 +14,7 @@ public function register(): void Event::listen('*', function (string $eventName, array $data) { $event = $data[0] ?? (object) null; - if(! is_object($event)) { + if (! is_object($event)) { return; } diff --git a/src/Support/Environment.php b/src/Support/Environment.php new file mode 100644 index 00000000..70f20367 --- /dev/null +++ b/src/Support/Environment.php @@ -0,0 +1,31 @@ +translateFromWindowsString(exec('tzutil /g')); } else { $timezone = $timezones->translateFromAbbreviatedString(exec('date +%Z'));