How Do I Work in 2022?

2022 年針對去年的工具進行一個全面性的覆盤和審視,目前在工具上做了一些調整, 以下會列出截至目前為止所變更的項目和工具選用以及用途作為一個參考紀錄。 開發 Updated 20220421 這個項目基本上沒有太大變化,其一是目前工作還是採用 PHP,後續如果有語言變更需求還是會是 以 Jetbrains 公司的編輯器做為首選,主要是很多使用和邏輯跟目前在使用的 PHPStorm 相同,加快開發效率 Jetbrains: PHPStorm VSCode: 目前主要作為其他語言編輯器,方便跟快速啟動是我選擇原因 SetApp: 目前主要是 TablePlus 以及幾個方便記錄時間跟剪取編輯的工具為主要使用,有搭配一些日曆管理軟體,個人認為很划算的一個訂閱服務,不需要再花很多時間找尋工具 Alfred: 快速切換 toolbar,有綁定一些 workflow,但主要還是搜尋和計算不需要再額外打開其他應用加快速度(也許會替換成 raycast,觀望中) Carbon / Nord theme for all editors, JetBrains Mono type. 管理 Updated 20220421 TickTick: 目前還是我生活和工作上的 GTD 管理工具,生活上除了日常待辦事項紀錄外,習慣養成和快速筆記我也是使用這套軟體,工作上則是切換成看板作為進度控制,這也是為數不多讓我覺得很好用的工具 知識來源 Youtube Premium: 這個投資也是相當實際,節省掉我大量的等待廣告時間,且上面有許多免費的學習資源很推薦購買 Udemy: 課程購買平台,通常都可以用很實惠的價格買到不錯的課程 硬體 Macbook pro/air M1 -> shifting to new Macbook Windows 11 keychron K3 Logitech G PRO superlight / Master 3 iPhone 13 pro max iPad pro 11'

March 27, 2022 Â· 1 min Â· Yish

Laravel Assert Middleware

In my case, I would like to assert the middleware what I through, Here is my soulution. // TestCase or what you like to put in. public function assertMiddleware($middleware, $request = null, ...$args) { // To be sure it's implemented handle method. if (! method_exists($middleware, 'handle')) { throw new BadMethodCallException(); } // Does it need to customize request? $request = $request?:new Request(); // instanced and called from handle. $instance = App::make($middleware)->handle($request, function($request) { return new JsonResponse($request); }, ....

March 27, 2022 Â· 1 min Â· Yish

Artisan Exit Code in Laravel

References from laracasts discussion, also I got a other reference. refs code Useful codes: 1 = failing / failed 2 = not ready 0 = success / no error….

March 25, 2022 Â· 1 min Â· Yish

Push middleware into global middleware in laravel

For my situation, I need to append debugbar infomation into APIs response when JSON API respond, here is my solution. You can make other sevice provider for this, but I just want to make a concept for you, so put in AppServiceProvider. What’s position that I want to put on, see in below: class Kernel extends HttpKernel { protected $middleware = [ // Here is prepend position. // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, // Here is push position....

March 25, 2022 Â· 1 min Â· Yish

Ignoring specific listeners

We can ignore the listeners when we use event() dispatching event, here is how to implement it. The flow is very simple, passing ignore listeners when we called event, and then ignore it. For example, I have a event with listeners: class EventServiceProvider { protected $listen = [ UserCreated::class => [ SentToAdmin::class, SentToManager::class, NotifyUser::class, // we want to ignore it by specify situation. ] ] } class UserController { public function createByAdmin(Request $request) { $user = User::query()->create($request->validated()); event((new UserCreated)->ignoreListeners([ NotifyUser::class // listener ])); ....

March 10, 2022 Â· 1 min Â· Yish

Laravel Customize Query Builder

For my situation, I need to use complex query conditions for my cases, I want to aggregate my conditions in my entity, so I decided to extend the query builder. We know laravel providing the method to allow you customize Eloquent builder: newEloquentBuilder, but I want to more easy to use, almostly, I want to out of the box. So I’m following below to think, starting with my ideal. Model class User extend Model // you can set the contract....

December 4, 2021 Â· 2 min Â· Yish