Certbot による certification の更新ができなかった場合

Certbotによる certification の更新が何らかの理由(サーバーインスタンスを停止していた/ネットワークを公開していなかった等)により自動更新できなかった場合 solution) sudo certbot run -v

adminMongo で private subnet に設置した mongoDB からデータを取得する

環境: mongoDB を private subnet に設置 adminMongo を public subnet に設置 github.com @public subnet App instance cd projectDirectory git clone https://github.com/mrvautin/adminMongo.git && cd adminMongo cd adminMongo adminMongo/config/app…

sudo apt update でエラー:W: GPG error: https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A26B1AE64C3C388 E: The repository 'https://repo.mongod

sudo apt update で下エラー W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release: The …

mongoDB: Upgrade した直後、mongod で DB がすぐにシャットダウンしてしまう

環境: mongoDB@4.2 から @6.0.6 にアップグレード error: This version of MongoDB is too recent to start up on the existing data files. Try MongoDB 4.2 or earlier solution: root ディレクトリの data フォルダを削除して再度dataフォルダを設置 ref…

jenssegers / laravel-mongodb ランダムなレコードを取得する

環境: Laravel@9.52.4 jenssegers/laravel-mongodb@3.9.5 $Posts = Post::raw(function($collection) { return $collection->aggregate([ ['$sample' => ['size' => 5]], ['$project' => ['title' => 1, 'body' => 1]] ]);}); ref: www.codegrepper.com gith…

Laravel: forPage() で page によって返値が配列になったりオブジェクトになったり

環境: Laravel@9.52.4 事象: Laravel でforPage() を使ってPagination を実装したがページによってオブジェクトが返ってくる。 ↓↓正常な挙動(配列が返る) ↓↓異常な挙動(オブジェクトが返る) ↑↑(indexがfilter()により抜けがある) solution) 同じロジックでp…

mongoDB の効率的なデータベース設計 ChatGPT曰く

>>> 頻繁に検索するならフラットに、そうでなくてかつデータの関連性を維持したいならネストもあり。 >>> 検索対象が小規模ならメンテナンスのことを考えてアプリケーション側の処理のしやすさを優先させてもいいかも。

Laravel: migration file を削除してしまい php artisan migrate:reset でエラー

環境: Laravel@9.52.4 migrate 済みの migration ファイルを削除してしまい、php artisan migrate:reset で Migration not found とエラーが出てしまった場合。 solution) php artisan migrate:fresh >>> DB全てのテーブルが削除された後、migrate する処理 …

php artisan db:seed >>> Target class [hoge] does not exists

seeder の namespace が間違っていた seeder を編集しても適用されない場合があるので編集したら composer dump-autoload

PHP マイナーアップグレード 8.0.x to 8.2

PHP

sudo add-apt-repository ppa:ondrej/php sudo apt show php インストールできるバージョンが表示される sudo apt-get update sudo apt-get install -y php ref: self-development.info

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…

Oracle Cloud + AWS SES + お名前ドットコム独自ドメイン によるメール配信初期設定

環境: お名前ドットコムで独自ドメインを取得 App Server は Oracle Cloud Infrastructure 上に構築 メール配信システムに AWS Simple Email Service を使用 1. 独自ドメインDNS設定で XXX.com にアクセス可能にする 下記参照 www.ashisuto.co.jp 2. SESに…

Oracle Cloud Infrastructure: private subnet に設置した mongoDB server に public subnet からアクセスする

Updated: 2023/3/7 環境: App server と mongoDB 設置 server は同一VCN内にあり、App server は public subnet, mongoDB は private subnet 内に設置。 OSはともにubuntu@20.04 mongoDB@5.0.3 Public Subnet の Security Group Egress 宛先:Private Subnet…

Solved: Laravel で web.php で適切にroutingしているのにホーム以外が404エラーになる

環境: ubuntu@20.0.4 Apache@2.4.49 事象: Apache使用時 solution: sudo apachectl -S で各ポートのコンフィグファイルを確認 sudo vi 000-default-ssl.conf (↑確認されたコンフィグファイル) <Directory ~> ~ </Directory> を加筆 ref: qiita.com

Solved: PHPが正常に読み込まれず、プレインテキストを出力するようになった。libapache2-mod-php8.0 がインストールされているのに a2enmod libapache2 できない

PHP

事象: 正常にPHP、apacheがインストールされた後にapacheをアンインストールしたらPHPが読み込まれずindex.php内のplain textがアウトプットされるようになった。 solution: PHP、Apacheを完全にアンインストールして再インストール sudo apt-get purge apa…

Solved: Certbot: sudo certbot renew --dry-run でエラー

sudo certbot renew --dry-run Failed to renew certificate xxx.com with error: Some challenges have failed. 上記のエラーが発生した場合、 sudo certbot run -v 2: Renew & replace the certificate 後に sudo certbot renew --dry-run で解決

Oracle Cloud Infractructure: ubuntu@20.0.4 Let's encrypt を使ってHTTPS化

追記: 2022/5/7 対象インスタンスにSSH接続 Certbotのインストール Certbotとは証明書の導入、自動更新をしてくれるツール Certbotのインストールにsnapdのインストールが必要 ref: letsencrypt.org snapdのインストール ref: snapcraft.io snapdを最新にア…

solved: Oracle Cloud Infrastructure: ubutun@20.0.4: sudoersをいじくってsudoが出来なくなった件

事象: /etc/sudoers をvisudoを使用しないでviで編集してsyntaxエラーがあったためsudoコマンドが使用不可に。sudoersも編集できなくなって詰んだ 環境: oracle cloud infrastructure ubuntu@20.0.4 public subnet 作業の流れ: 当該インスタンスからboot v…

AWS Cloud9 で private subnet を追加して private subnet 内に立てた instance に SSH 接続する 力技

背景: cloud9 で mongodb を利用するとき app server と同一の EC2 インスタンスにmongoDB をインストールして使用したが、より本番環境に近い private subnet 内に EC2 インスタンスを立て、そこに mongodb server を作ることを試みた。 流れ: cloud9 と同…