2022-01-01から1年間の記事一覧

Laravel: Cannot trigger ORM model event static::restored

環境: laravel@8.83.23 事象: Model を soft-delete し、その後 restore 時に特定の処理をしたいが処理が実行されない。 cannot works: @models/User.php protected static fucntion boot() { parent::boot(); static::deleted(function ($user) { $user->pr…

Laravel + MongoDB: error: Indirect modification of overloaded property App\....

環境: laravel@8.83.23 jensseger/laravel-mongodb@3.8.0 Model Structure Profile: { roles: [’admin’] } $profile = App\Profile::find(1); $profile->roles = array_push($profile->roles, 'superAdmin') >>> error: Indirect modification of overloade…

VueJS: handling edge case - http request で得た値をprops として子component にパスした時、mounted で値を加工しようとしたらprops の取得タイミングの都合で正しい値を取得できない。さらにその値を編集したい場合

http request で得た値をprops として子component にパスした時、mounted で値を加工しようとしたらprops の取得タイミングの都合で正しいprops の値を取得しないで処理されてしまうエラーの回避。さらにその値を編集したい場合。 環境: vue@2.6.12 @親コン…

Vuetify badge Component のテキストスタイルを変更する

環境: vuetify@2.6.6 <v-badge color="primary red--text font-weight-bold"> primary >>> バッジ自体のカラー red--text >>> バッジ内のテキストカラー</v-badge>

Laravel Cashier chips

環境: laravel@8.79.0 laravel/cashier@13.8.6 payment method 一覧の取得 $user->paymentMethods() 任意の paymentMethod の詳細を取得 $user->paymentMethods()[0]->asStripePaymentMethod() default paymentMethod の取得(設定していれば) $user->default…

Vuex state を form に使うとき、入力と同時に state が更新されてしまう問題

環境: vue@2.6.14 vuex@3.6.2 <v-text-fileld v-model=$store.state.userData.nickname></v-text-field> このように state をバインドすると値が入力するたびに stateが更新されるため、フォームが submit されようと cancel されようと関係なく submit 扱いになってしまう。 solution) フォームで編集したいデータを値渡しで格納す…

Laravel + mongoDB find deepley nested collection with array

環境: laravel@8.79.0 Jenssegers/mongodb@3.8.4 サーチ対象の model 構造は以下とする Order { _id: ********, shippingStatus: [ "status" => "発送完了", "shippingMethod" => "クロネコヤマト", "inquiryNumber" => "11111111" ] } Order model から shi…

Laravel: 親モデルを削除と同時に子モデルを削除する cascading soft-delete / MySQL case and MongoDB case

環境: Laravel@8.79.0 Jenssegers/mongodb@3.8.4 前提: 親モデル >>> User.php MySQL子モデル >>> Post.php MongoDB子モデル >>> ProfileDetail.php case MySQL soft-delete に対応させる migration file に以下を加筆 Schema::create('users', function B…

Laravel MongoDB: mongodbを使用時にmigration file で table を定義する

環境 Laravel@8.79.0 Jenssegers/mongodb@3.8.4 migration をしなくても ORM から query することで DB に table を作成することができるが、 migration file を作って DB table を定義したい場合、 php artisan make:migration create_MONGO_TABLE_MODEL_ta…

Laravel MongoDB: Delete a table and items manually

環境 Laravel@8.79.0 Jenssegers/mongodb@3.8.4 php artisan tinker >>> @tinker session // Delete a table Schema::connection('mongodb')->drop('TABLE_NAME') // Delete items DB::connection('mongodb')->table('TABLE_NAME')->truncate() ref: stackov…

Laravel と Vuejs の連携 laravel 側の データを vuejs template 内で使用する

Updated: 2024_02_16 環境: laravel@8.79.0 vue@2.6.14 @app.blade.php <div id="vue"> <app-pageBody :passing-data="`{{ Sesssion::get('passingData'); }}`"></app-pageBody> 必ずバッククォート``で囲う </div> @someController.php session()->put('passingData', "Hello this is a passing data"); @PageBody.vue props: ['passingD…

VueJS Browser back を検知する detect browser back

環境: vue@2.6.14 vuex@3.6.2 @app.js history.replaceState(null, '', null)window.addEventListener('popstate', function() { vue.$store.commit('ROUTER_DETECT_BROWSER_GO_AND_BACK')}) @router.js const state = { detectBrowserGoAndBack: 0 } const…