Laravel

Laravel でフロント側からのクエリパラメーターの処理

フロントからクエリパラメーターを二つ付けて送った where では intval() で型を変える必要があったがforPage() では $request->page のままで処理が可能だったことに注意 //

vue-infinite-loading と laravel の連携

updated: 2018/10/3 @vue ?page=1 のクエリを添えてGET @laravel $request->page で欲しいpage番号を指定 forPage() はpage1 と page2以降で返り値の挙動に差があるエラーがあるので下記参照 github.com // gist.github.com

Laravel 5.x Factory と Faker で relational なモックアップを作る。

updated: 2021/6/1 jenssegers/mongodb の mysql relationships で使用可能なことが確認済み php artisan make:factory FACTORY_NAME factory1 factory2 seeds/DatabaseSeeder.php おまけ ランダムな文字列を生成 return [ 'randomText' => $faker->regexify…

php artisan db:seed でエラー

データベーステーブルを適切に削除しなかったため。 solution: php artisan migrate:refresh //

jenssegers/laravel-mongodb Installation on php7.2 cloud9

Updated: 2018/9/27 php7.2 を cloud9 にインストール monteecristoo.hatenablog.com MongoDB のインストール monteecristoo.hatenablog.com PHP 用の MongoDB ドライバーをインストール PHP: Installing the MongoDB PHP Driver with PECL - Manual sudo pe…

Laravel blade template と VueJS の連携 blade template 内の vue component にデータをパスしたい

updated: 2022/2/18 より良い方法: monteecristoo.hatenablog.com blade template 内の vue component にデータをパスしたい場合 例えば authHome.blade.php / guestHome.blade.php の二つに共通で PageBody.vue という vue component を使うとき、Laravel …

Laravel + VueJS : VueJS component 内のどこからでも jquery を使用できるようにする Laravel Mix

updated: 2018/5/2 この記事は検証途中で内容が不正確 方法1 Laravel Mix から @webpack.mix.js let webpack = require('webpack'); mix.webpackConfig({ plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jquery: 'jquery', window.jquery: 'jquery' …

Laravel-Mix issue sass scss .sourceMaps() を使っても chrome debugger で表示されないとき

// mix.js('resources/assets/js/app.js', 'public/js') .js('resources/assets/js2/app2.js', 'public/js/app2.js') .sass('resources/assets/scss/app.scss', 'public/css') .sass('resources/assets/scss/style.scss', 'public/css') .sass('resources/as…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7⑧ sample case

// App\User ===> App\MongoMessage Mysql Relationships App\MessageGroup ===> App\MongoMessage hasMany Relationships App\User public function mongoMessages() { return $this->hasMany(MongoMessage::class); } App\MessageGroup public function mo…

Laravel 5.x よく使う query builder

// updated: 2018/4/14 first() get() >>> get() で複数の collection が返ってくるのでさらに処理したい場合は foreach で処理 e.g.) $messages = App\Message::whereNull("body")->get(); foreach($messages as $message) { $mssage->delete(); } whereIn(…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7⑦ convert mongoDB to Mysql

// setting up Mysql Relationships create the route and controller fetch the data from mongoDB extract the value from the response(3) fetch the data from Mysql using the value(4) return the response 1. @app\user use Jenssegers\Mongodb\Eloqu…

Laravel + VueJS multi vue files loading

// @webpack.mix.js mix.js('resources/assets/js/app.js', 'public/js') .js('resources/assets/js2/app2.js', 'public/js'); @resources/assets/js/app.js app.js に実装したい routing, components を読み込むconst routes = [ { path: '/user/:id', comp…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7⑤ EmbedsMany relationships test

// tinker $mongoUser = new MongoUser(['id' => 1, 'name' => 'Max']); $mongoMessage = new MongoMessage(['id' => 1, 'group' => '1', 'body' => 'Something', 'sender' => 'max', 'receiver' => 'Monica']); $mongoMessage = $mongoUser->mongoMessages(…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7④

// App/MongoUser namespace App; use Moloquent; use MongoMessage; class MongoUser extends Moloquent{ protected $connection = 'mongodb'; protected $collection = 'mongoUsers'; public function mongoMessages() { return $this->embedsMany('MongoM…

error: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = c9 and table_name = migrations)

// cloud9 上で php artisan migrate:reset 時に下記のエラー SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = c9 and table_name = migrations) composer dump-autoload してもダメな時 な…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7③ 導入するメリット

// updated: 2018/3/6 jenssegers/laravel-mongodb を導入するメリット MySQL Relations If you're using a hybrid MongoDB and SQL setup, you're in luck! The model will automatically return a MongoDB- or SQL-relation based on the type of the rela…

mozjpeg コンパイリングエラー cloud9

// cloud9 で Laravel mix 使用時、下記のエラーが発生 cjpeg: error while loading shared libraries: libpng16.so.16 error write epipe エラーがどのタイミングで発生したか把握していない ubuntu 特有のエラーかも 環境: Ubuntu 14.04.5 LTS (cloud9) la…

Error: In Database.php line 198: No suitable servers found ('serverSelectionTryOnce' set) : [connection refused calling ismaster on '127.0.0.1:27017']

updated: 2018 9/26 Error: In Database.php line 198: No suitable servers found ('serverSelectionTryOnce' set) : [connection refused calling ismaster on '127.0.0.1:27017'] mongoDB と mysql を使った multiple Database 環境で php artisan migrat…

jenssegers/laravel-mongodb Basic Usage on cloud9 with php7 ①

// updated 2018/1/5 Installation monteecristoo.hatenablog.com monteecristoo.hatenablog.com Laravel Configuration @config\app.php add the service provider Jenssegers\Mongodb\MongodbServiceProvider::class, @config/database.php 'mongodb' => […

jenssegers/laravel-mongodb installation PHP7.1 on cloud9

updated: 2018/9/25 jenssegers/laravel-mongodb installation PHP7.1 on cloud9 updated: 2017/12/14 下記に従ってmongoDBをインストール。 monteecristoo.hatenablog.com composer require jenssegers/mongodb → error: Problem 1 - jenssegers/mongodb v3…

Laravel & redis 接続テスト

Installation composer require predis/predis @web.php Route::get('/redis_test', function() { print_r(app()->make('redis')); } // Illuminate\Redis\RedisManager Object ( [driver:protected] => predis [config:protected] => Array ( [default] => …

Setting Up MongoDB on cloud9 Laravel project

// community.c9.io www.compose.com https://teratail.com/questions/41471

Laravel mail notification with pusher and mailtrap

// Laravel で pusher を使った notification を受けて mailtrap 経由で通知メールを送る。 monteecristoo.hatenablog.com 上記の続き @.env mailtrap のアカウント情報を記入 MAIL_DRIVER=smtpMAIL_HOST=smtp.mailtrap.ioMAIL_PORT=2525MAIL_USERNAME=YOUR …

Noty installation with Laravel + Vue.js App

npm install noty --save @resources/assets/js/bootstrap.js window.noty = require('noty'); @app.blade.php <script> @if(Session::has('success')) new noty({ type: 'success', layout: 'bottomLeft', text: '{{ Session::get('success') }}' }); @endif </script> -----…

Laravel Echo を使ってnotification の実装 with Pusher

// Laravel Echo : A JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by Laravel. Installation composer require pusher/pusher-php-server "~3.0" 参考: laravel.com Problem 1 - Installation re…

Laravel update 5.4 to 5.5

// composer.json ファイルを github.com をコピーしてペースト。 composer.jsonの自分でカスタマイズした部分をペースト。 composer update php artisan --version でアップデートを確認。 参考: laravel.com www.youtube.com

Vue.js within Laravel 5.x

Laravel 内の Vue.js vue-loader@13.0.4にアップデートすると [Vue warn]: Failed to mount component: template or render function not defined. とエラーが出るので vue-loader@12.2.2 を使用(要検証) yarn add vue-loader@12.2.2

Laravel pagination backend setting with Vue.js

@relationships.php public function res_recommend() // users not follow { $fs = $this->follows()->get(); // Auth_userがfollowしているuser $follows = array(); foreach($fs as $f) { array_push($follows, $f->target_id); } array_push($follows, $…

Laravel5.4 ORM + PHP Traits

// ORMにfunctionを追記出来るがreusableでなく、肥大化することがあるためtraitsを使うことがある。 TraitsやORMのfunctionはmethod chainやORM向けのmethodを使用できる点で優れる。 @App\foo.php (ORM) use App\Traits\Friendable; class User extends Au…

Laravel blade template でVueを使うときの注意 稀なエラー

blade templateで@section('hoge')を設定したのち、 vue側のapp.jsでvueをinjectするタグを以下のように同じ<hoge>に設定すると… Vue.component('hoge', require('./componets/Hoge.vue')); エラー(コンソールにもコンパイル時もエラーが表示されない)でvueが表示</hoge>…