Laravel Migrations: Foreign Key on different connection (different DB)

Possible in Laravel 5 Schema::create(‘posts’, function (Blueprint $table) { …. $table->integer(‘user_id’)->unsigned()->nullable(); $table->foreign(‘user_id’)->references(‘id’)->on(‘auth.users’)->onDelete(‘cascade’); }); This will reference to the users table on the auth database. Question How can I make it though that it looks in the auth connection, rather than directly in the auth database? Reason I’m asking because each developer or environment could have…

Laravel Eloquent join throug pivot tables

Unfortunately, I don’t have that much experience with Eloquent yet. I try to create a query from three tables which have two pivot tables. My tables: My Models: Player class Player extends Model { protected $table = ‘players’; protected $fillable = [ ‘name’ ]; public function layout(){ return $this->belongsToMany(‘App\Layout’, ‘layout_player’, ‘player_id’, ‘layout_id’); } public function…

Add laravel migrations with foreign keys

I have created a table called ‘users’.There are tables called ‘companies’,’designations’,’departments’.I want to add company_id,designation_id,department_id columns to users table as foreign keys. I tried this but it didn’t work public function up() { Schema::table(‘users’, function (Blueprint $table) { $table->integer(‘department_id’); $table->integer(‘company_id’); $table->integer(‘designation_id’); $table->foreign(‘department_id’)->references(‘id’)->on(‘departments’)->onDelete(‘restrict’)->onUpdate(‘restrict’); $table->foreign(‘company_id’)->references(‘id’)->on(‘companies’)->onDelete(‘restrict’)->onUpdate(‘restrict’); $table->foreign(‘designation_id’)->references(‘id’)->on(‘designations’)->onDelete(‘restrict’)->onUpdate(‘restrict’); }); } public function down() { Schema::table(‘users’, function (Blueprint $table) {…

Parse Laravel exception using regex

Good time of the day, I am trying to parse the Laravel log for exceptions (and other types of messages) using the JackieDo/Laravel-Log-Reader, however, there is a problem with getting the exception data. The input string is: Argument 1 passed to App\Classes\Storage\AbstractStorage::formatBytes() must be of the type int, null given, called in /app/app/Classes/Storage/PlexStorage.php on line…

How to get this code work to store in Laravel. No errors and no storage

I can’t store name and IP address to DB. I created a table ‘info’ with appropriate fields by running php artisan migrate. A schema Schema::create(‘info’, function (Blueprint $table) { $table->increments(‘id’); $table->string(‘name’); $table->string(‘ip’); $table->timestamp(‘created_at’)->nullable(); }); A model for Info class Info extends Model { protected $fillable = [‘ip’, ‘name’]; } Maybe the problem is in my…