Laravel

Laravel5.4 ORM + Traits + Controller + Routes

level 1. routes.phpに全部記述 leavel 2. controllerを使ってrouteへの記述量を減らす level 3. Eloquent ORMを使ってroute、controllerの記述量を減らす level 4. ORMにTraitsを付与してORMの記述量を分散 cati #9 TraitsやORMへの記述はcontroller側にも…

Laravel5.4 ORMにexternal functionを付与

例えばApp\Userに外部からfunctionを付与したい場合 @Http直下に以下を設置 @Http\ExternalFunc\Greeting.php

oauth認証で突然動作不良が起きたら… Received HTTP status code [401] with message "<?xml version="1.0" encoding="UTF-8"?> <hash> <error>The given URL is considered malware</error> <request>/oauth/request_token</request> </hash> " when getting temporary credentials.

oauth認証が突然出来なくなった → 原因: ドメインがSpamhausのブロックリストに登録されたため 確認方法: oauth認証先のセッティング画面でcallbackURLを変えてみる 例えばtwitterでは… とアラートが出るのでシステムの問題ではなくドメインブロックの問題…

Laravel5.4 + VueJS CSRF token error: TokenMismatchException in VerifyCsrfToken.php line 68:

middleware->('auth')を使用時form関連を扱うときtokenが必要 純粋なLaravel App なら blade templateの {{ csrf_token() }} からtokenを取得して <input type="hidden" name="_token" value="7YC0Sxth7AYe4RFSjzaPf2ygLCecJhblahblah"> をセット、または <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"> で解決できるがvueの場合や外部のパッケージを利用し…

Laravel5.4 Laravel-Mix issue  Error: Module build failed: Error: Couldn't find preset "es2015" relative to directory

// updated: 2018/2/13 Error: Module build failed: Error: Couldn't find preset "es2015" relative to directory laravel-mixがes2015を認識していない npm install babel-preset-es2015 --save-dev プロジェクトのroot directoryに.babelrc { "presets":…

Laravel + vue-router vue SPAページのRouting @vueJS inside Laravel

基本 app.jsで記述したpathをlaravel側のweb.phpにも記述。その際、returnするviewはvueの起点ページにする。 Route::get('/profile', function() { return view('home'); }); → home.blade.phpにvue componentのprofileがある場合、profileがレンダリングさ…

Laravel Migration file 操作

// php artisan make:migration create_messages_table --create="messages" Schema::create付きのmigration fileが生成される。 function up → php artisan migrate した時の動作 funciton down → php artisan migrate:rollback した時の動作 migrateをやり…

Laravel 5.4 Database Structure

Relationships model A: User protected $fillable = [ DBのカラム] public function messages) { return $this->hasMany(Message::class); } model B: Message protected $fillable = [ DBのカラム] foreign_key は登録しなくてOK public function users() …

cloud9上のLaravelアプリケーション内のnode server(今回はredis)とsocket.ioでLaravelアプリケーション内のVueJSからwebsocket通信をするとき

// updated: 2018/7/9 node_server側 プロジェクト直下にmkdir node_server npm init → entry point は server.js npm install redis express socket.io @/node_server/server.js var app = require('express')();var server = require('http').Server(app);…

Laravel tinker Basic Usage

// テスト用データベースを作成 php artisan make:model Test -m php artisan migrate (phpmyadmin-ctl install) tinkerを起動 php artisan tinker tinker console内で... $test = App\Test::create(); => App\Test {#715 updated_at: "2017-05-08 05:43:30"…

LaravelMixのVueJSにES6 syntax spread operator

npm install --save-dev babel-plugin-transform-object-rest-spread add .babelrc in your project directory { "plugins": ["transform-object-rest-spread"] } 参考: can't compile object spread operator unexpected token error · Issue #76 · Jeffre…

Laravel 5.4 Laravel Mix error: SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

cloud9上のubuntuのnodeのversionが古いため発生。 → nvm install stable ・・・nodeをupdate → npm run dev ・・・正常に動作

Laravel5.4 + cloud9 php artisan migrate error

php artisan migrate → [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_emai l_unique`(`email`))…

Laravel5.4 php artisan make:migration エラー処理

php artisan make:migraiton create_xxx_table 入力時のエラー include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to open stream: No such file or directory 一旦作ったmigrationファイルを…

Laravel 5.4 laravel-mix issue

laravelインストール後 →npm install →npm run dev →ミックスされたapp.js生成 →TypeError: Cannot read property 'csrfToken' of undefined →もう一度npm run dev→error: jsにエラーがあるため 各々のファイルに ① <script> window.Laravel = <?php echo json_encod</script>…

cloud9にphp7とLaravel5.xをインストール

// updated: 2021/5/15 sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install libapache2-mod-php7.2 sudo a2dismod php5 sudo a2enmod php7.2 sudo apt-get install php7.2-dom php7.2-mbstring php7.2-zip php7.2-mysql php7…