laravel-schema-builder

Laravel 5.3 Schema::create ENUM field is VARCHAR

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-23 08:53:46
问题 I just created fresh migration. After running it I see my field type not ENUM type . It has a VARCHAR(255) type instead Schema::create('payments', function (Blueprint $table) { $table->increments('id'); $table->text('response'); $table->enum('type', ['apple', 'paypal']); $table->smallInteger('flags'); $table->timestamps(); }); Can somebody tell me what can be the reason. Am I missing something, I tried multiple times - getting same result. I'm using PostgreSQL 9.5.4 回答1: From the Laravel

How to optimize query statement in Laravel 7?

我只是一个虾纸丫 提交于 2020-04-14 06:13:29
问题 I show code in the screenshot, because I want to show you guys my line 43 The actual code is here : public function index() { $inputs = Request::all(); $interval = ''; if(array_key_exists('interval', $inputs)){ $interval = $inputs['interval']; } switch ($interval) { case 'day': $visitors = Visitor::where('created_at', '>', now()->today())->paginate(20);; break; case 'week': $visitors = Visitor::where('created_at', '>', now()->subMonth())->paginate(20);; break; case 'month': $visitors =

How to set auto increment into non primary key?

旧城冷巷雨未停 提交于 2019-12-12 18:17:22
问题 How would I set a database auto increment field that is not a primary key on the creation method? The only way is using a raw query? DB::statement('ALTER TABLE table CHANGE field field INT(10)AUTO_INCREMENT'); 回答1: It is not implemented to do so. However, I found this over at the Laravel Forums: Schema::table('table', function(Blueprint $t) { // Add the Auto-Increment column $t->increments("some_column"); // Remove the primary key $t->dropPrimary("table_some_column_primary"); // Set the