laravel Production-ready

https://serversideup.net/open-source/spin/ Laravel sail https://laravel.com/docs/11.x/installation#choosing-your-sail-services shinsenter laravel https://github.com/shinsenter/php/pkgs/container/laravel

2024-08-28 · 1 min · 7 words · Me

php artisan config:cache

https://serversideup.net/open-source/docker-php/docs/laravel/laravel-automations#php-artisan-configcache This command caches all configuration files into a single file, which can then be quickly loaded by Laravel. Once the configuration is cache, the .env file will no longer be loaded.

2024-08-15 · 1 min · 32 words · Me

Two dimensional Array unique

$goods = [ 1 => [ 'id' => 12, 'price' => 77, ], 2 => [ 'id' => 43, 'price' => 855, ], 4 => [ 'id' => 34, 'price' => 1, ], ]; $goods_unique_ids_keys = array_keys(array_unique(array_column($goods, 'id'))); $goods_filter_datas = array_filter($goods, fn($key) => in_array($key, $goods_unique_ids_keys), ARRAY_FILTER_USE_KEY);

2024-02-20 · 1 min · 46 words · Me

Livewire form and outside form with button action maybe different your think

In liveiwre word some button action and alpine @click action be clicked, livewire 3 update (ajax) is different your think. Component public $test_input=1; public function tt() { info('tt'); info($this->test_input); } blade <div class="row row-cols-1 row-cols-md-3 g-4" x-data> <form wire:submit="tt"> <input type="text" wire:model='test_input'> <button type="submit">form type=submit</button> {{-- // update (ajax) --}} <button type="button">form type=button</button> {{-- // No update (ajax) --}} <button wire:click='tt; $wire.test_input=3;'>form wire:click</button> {{-- // update (ajax) and run twice --}} <button @click='$wire.tt; $wire.test_input=3;'>form @click</button> {{-- // update (ajax) and run twice --}} </form> <button type="submit">out form type=submit</button> {{-- // No update (ajax) --}} <button type="button">out form type=button</button> {{-- // No update (ajax) --}} <button wire:click='tt; $wire.test_input=3;'>out form wire:click</button> {{-- // update (ajax) --}} <button @click='$wire.tt; $wire.test_input=3;'>out form @click</button> {{-- // update (ajax) --}} </div> So be careful and try to understand ...

2023-12-31 · 1 min · 147 words · Me

Codeigniter 4 ORM relation By hand Part 2

Modify ModelTrait file at \App\Traits namespace App\Traits; trait ModelTrait { // fetaure Maybe belongsTo // get result but not effect this, keep this ORM status public function newSelfObject() { return $this->db->query($this->builder->getCompiledSelect(false)); } // copy self object return ORM Object public function cso() { $class_name = get_class($this); $class_new_object = (new $class_name); $class_new_object->builder = clone $this->builder; return $class_new_object; } public function hasOne($class, $relation_primary_key=null, $primary_key=null) { return $class->where($relation_primary_key ?? $this->primaryKey, $this->newSelfObject()->getRowArray()[$primary_key ?? $this->primaryKey] ?? ''); } // whereIn If can't get records, return null. Usually use primaryKey cloud happen public function hasMany($class, $relation_primary_key=null, $primary_key=null) { $temp = array_column($this->newSelfObject()->getResult(), $primary_key ?? $this->primaryKey); return $class->whereIn($relation_primary_key ?? $this->primaryKey, empty($temp) ? [null] : $temp); } } App\Controllers\OrderListContriller.php ...

2022-12-29 · 1 min · 147 words · Me