mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
Updates About Field Default
Updates the about column to have a default of an empty string. Curse you, MySQL!
This commit is contained in:
parent
6bc02ca210
commit
4e33dd9ec5
@ -8,6 +8,7 @@ use App\Notifications\VerifyEmail;
|
|||||||
use App\Traits\HasCoverPhoto;
|
use App\Traits\HasCoverPhoto;
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
@ -209,6 +210,24 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
return $filters->apply($builder);
|
return $filters->apply($builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the about default value if empty. Thanks MySQL!
|
||||||
|
*/
|
||||||
|
protected function about(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
set: function ($value) {
|
||||||
|
// MySQL will not allow you to set a default value of an empty string for a (LONG)TEXT column. *le sigh*
|
||||||
|
// NULL is the default. If NULL is saved, we'll swap it out for an empty string.
|
||||||
|
if (is_null($value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the disk that profile photos should be stored on.
|
* Get the disk that profile photos should be stored on.
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ return new class extends Migration
|
|||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->longText('about');
|
$table->longText('about')->nullable()->default(null);
|
||||||
$table->foreignIdFor(UserRole::class)
|
$table->foreignIdFor(UserRole::class)
|
||||||
->nullable()
|
->nullable()
|
||||||
->default(null)
|
->default(null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user