Merge pull request #359 from shikorism/fix/ej-source-nonnull
ejaculations.sourceはNULL非許容にする
This commit is contained in:
commit
0218035aeb
@ -17,7 +17,7 @@ class Ejaculation extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'ejaculated_date',
|
||||
'note', 'geo_latitude', 'geo_longitude', 'link',
|
||||
'note', 'geo_latitude', 'geo_longitude', 'link', 'source',
|
||||
'is_private', 'is_too_sensitive'
|
||||
];
|
||||
|
||||
@ -49,8 +49,7 @@ class Ejaculation extends Model
|
||||
|
||||
public function scopeOnlyWebCheckin(Builder $query)
|
||||
{
|
||||
return $query->where('ejaculations.source', null)
|
||||
->orWhere('ejaculations.source', '<>', Ejaculation::SOURCE_CSV);
|
||||
return $query->where('ejaculations.source', Ejaculation::SOURCE_WEB);
|
||||
}
|
||||
|
||||
public function scopeWithLikes(Builder $query)
|
||||
|
@ -57,6 +57,7 @@ class EjaculationController extends Controller
|
||||
'ejaculated_date' => Carbon::createFromFormat('Y/m/d H:i', $inputs['date'] . ' ' . $inputs['time']),
|
||||
'note' => $inputs['note'] ?? '',
|
||||
'link' => $inputs['link'] ?? '',
|
||||
'source' => Ejaculation::SOURCE_WEB,
|
||||
'is_private' => $request->has('is_private') ?? false,
|
||||
'is_too_sensitive' => $request->has('is_too_sensitive') ?? false
|
||||
]);
|
||||
|
@ -8,5 +8,6 @@ $factory->define(Ejaculation::class, function (Faker $faker) {
|
||||
return [
|
||||
'ejaculated_date' => $faker->date('Y-m-d H:i:s'),
|
||||
'note' => $faker->text,
|
||||
'source' => Ejaculation::SOURCE_WEB,
|
||||
];
|
||||
});
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use App\Ejaculation;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MakeNonNullableSourceOnEjaculations extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::statement('UPDATE ejaculations SET source = ? WHERE source IS NULL', [Ejaculation::SOURCE_WEB]);
|
||||
Schema::table('ejaculations', function (Blueprint $table) {
|
||||
$table->string('source')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('ejaculations', function (Blueprint $table) {
|
||||
$table->string('source')->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
@ -13,6 +13,14 @@ use Tests\TestCase;
|
||||
|
||||
class SettingTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seed();
|
||||
}
|
||||
|
||||
public function testDestroyUser()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
Loading…
Reference in New Issue
Block a user