Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // user class
- class User extends Authenticatable
- {
- use Notifiable;
- protected $fillable = [
- 'name', 'email', 'password',
- ];
- protected $hidden = [
- 'password', 'remember_token',
- ];
- protected $casts = [
- 'settings' => 'array'
- ];
- }
- // migration
- public function up()
- {
- Schema::create('users', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('email')->unique();
- $table->string('password');
- $table->json('settings')->nullable();
- $table->rememberToken();
- $table->timestamps();
- });
- }
- // test
- public function testCanVerifyJsonColumn()
- {
- $expectedData = [
- 'profile_picture' => 'profile picture',
- ];
- $user = factory(User::class)->create([
- 'settings' => $expectedData
- ]);
- $this->assertDatabaseHas('users', [
- 'settings' => json_encode($expectedData),
- ]);
- }
Add Comment
Please, Sign In to add comment