for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreatePromocodesTable extends Migration
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
Schema::create(config('promocodes.table', 'promocodes'), function (Blueprint $table) {
$table->increments('id');
$table->string('code', 32)->unique();
$table->double('reward', 10, 2)->nullable();
$table->text('data')->nullable();
$table->boolean('is_disposable')->default(false);
$table->timestamp('expires_at')->nullable();
});
Schema::create(config('promocodes.relation_table', 'promocode_user'), function (Blueprint $table) {
$table->unsignedInteger('user_id');
$table->unsignedInteger('promocode_id');
$table->timestamp('used_at');
$table->primary(['user_id', 'promocode_id']);
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('promocode_id')->references('id')->on(config('promocodes.table', 'promocodes'));
}
* Reverse the migrations.
public function down()
Schema::drop(config('promocodes.table', 'promocodes'));
Schema::drop(config('promocodes.relation_table', 'promocode_user'));
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.