Skip to content

Commit f68c31c

Browse files
committed
Rename twitter_handle field
1 parent 4d35ed6 commit f68c31c

File tree

11 files changed

+33
-42
lines changed

11 files changed

+33
-42
lines changed

app/Http/Requests/UpdateProfileRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function rules()
1212
'name' => 'required|max:255',
1313
'email' => 'required|email|max:255|unique:users,email,'.Auth::id(),
1414
'username' => 'required|alpha_dash|max:255|unique:users,username,'.Auth::id(),
15-
'twitter_handle' => 'max:255|nullable|unique:users,twitter_handle,'.Auth::id(),
15+
'twitter' => 'max:255|nullable|unique:users,twitter,'.Auth::id(),
1616
'bio' => 'max:160',
1717
];
1818
}
@@ -37,8 +37,8 @@ public function username(): string
3737
return (string) $this->get('username');
3838
}
3939

40-
public function twitterHandle(): ?string
40+
public function twitter(): ?string
4141
{
42-
return $this->get('twitter_handle');
42+
return $this->get('twitter');
4343
}
4444
}

app/Jobs/UpdateProfile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class UpdateProfile
2222
public function __construct(User $user, array $attributes = [])
2323
{
2424
$this->user = $user;
25-
$this->attributes = Arr::only($attributes, ['name', 'email', 'username', 'github_username', 'bio', 'twitter_handle']);
25+
$this->attributes = Arr::only($attributes, ['name', 'email', 'username', 'github_username', 'bio', 'twitter']);
2626
}
2727

2828
public static function fromRequest(User $user, UpdateProfileRequest $request): self
@@ -32,7 +32,7 @@ public static function fromRequest(User $user, UpdateProfileRequest $request): s
3232
'email' => $request->email(),
3333
'username' => strtolower($request->username()),
3434
'bio' => trim(strip_tags($request->bio())),
35-
'twitter_handle' => $request->twitterHandle(),
35+
'twitter' => $request->twitter(),
3636
]);
3737
}
3838

app/Notifications/PostArticleToTwitter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function generateTweet()
3434
$title = $this->article->title();
3535
$url = route('articles.show', $this->article->slug());
3636
$author = $this->article->author();
37-
$author = $author->twitterHandle() ? "@{$author->twitterHandle()}" : $author->name();
37+
$author = $author->twitter() ? "@{$author->twitter()}" : $author->name();
3838

3939
return "{$title} by {$author}\n\n{$url}";
4040
}

app/User.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class User extends Authenticatable implements MustVerifyEmail
3939
protected $fillable = [
4040
'name',
4141
'email',
42-
'twitter_handle',
42+
'twitter',
4343
'username',
4444
'password',
4545
'ip',
@@ -85,9 +85,9 @@ public function githubUsername(): string
8585
return $this->github_username;
8686
}
8787

88-
public function twitterHandle(): ?string
88+
public function twitter(): ?string
8989
{
90-
return $this->twitter_handle;
90+
return $this->twitter;
9191
}
9292

9393
public function gravatarUrl($size = 100): string

database/migrations/2020_07_16_185353_update_articles_table_add_shared_at_field.php renamed to database/migrations/2020_07_16_185353_update_articles_and_users_tables_to_include_share_information.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class UpdateArticlesTableAddSharedAtField extends Migration
7+
class UpdateArticlesAndUsersTablesToIncludeShareInformation extends Migration
88
{
99
public function up()
1010
{
1111
Schema::table('articles', function (Blueprint $table) {
1212
$table->dateTime('shared_at')->after('approved_at')->nullable();
1313
});
14+
15+
Schema::table('users', function (Blueprint $table) {
16+
$table->string('twitter')->after('email')->nullable();
17+
});
1418
}
1519
}

database/migrations/2020_07_18_122946_update_users_table_add_twitter_handle_field.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

resources/views/articles/_form.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:t
130130
</span>
131131
@endif
132132
</div>
133-
@unless (Auth::user()->twitterHandle())
133+
@unless (Auth::user()->twitter())
134134
<span class="text-gray-600 text-sm mt-4 block">
135135
Articles will be shared on Twitter. <a href="{{ route('settings.profile') }}" class="text-green-darker">Add your Twitter handle</a> and we'll include that too.
136136
</span>

resources/views/users/_user_info.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class="text-lio-700 text-3xl block flex items-center">
6262
</a>
6363
@endif
6464

65-
@if ($user->twitterHandle())
66-
<a href="https://twitter.com/{{ $user->twitterHandle() }}"
65+
@if ($user->twitter())
66+
<a href="https://twitter.com/{{ $user->twitter() }}"
6767
class="text-lio-700 text-3xl block flex items-center">
6868
<span class="flex items-center justify-center mb-1">
6969
<x-icon-twitter class="h-5 w-5 mr-2" />
7070
<span class="text-base">
71-
{{ '@' . $user->twitterHandle() }}
71+
{{ '@' . $user->twitter() }}
7272
</span>
7373
</span>
7474
</a>

resources/views/users/settings/profile.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
@error('username')
4242
@endFormGroup
4343

44-
@formGroup('twitter_handle')
45-
<label for="twitter_handle">Twitter handle</label>
46-
<input type="text" name="twitter_handle" id="twitter_handle" value="{{ Auth::user()->twitterHandle() }}" />
44+
@formGroup('twitter')
45+
<label for="twitter">Twitter handle</label>
46+
<input type="text" name="twitter" id="twitter" value="{{ Auth::user()->twitter() }}" />
4747
@error('twitter_handle')
4848
@endFormGroup
4949

tests/Feature/SettingsTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ public function users_can_update_their_profile()
2727
'name' => 'Freek Murze',
2828
'email' => 'freek@example.com',
2929
'username' => 'freekmurze',
30-
'twitter_handle' => 'freek-murze',
30+
'twitter' => 'freektwitter',
3131
'bio' => 'My bio',
3232
])
3333
->seePageIs('/settings')
3434
->see('Freek Murze')
3535
->see('freekmurze')
36-
->see('freek-murze')
36+
->see('freektwitter')
3737
->see('Settings successfully saved!')
3838
->see('My bio');
3939
}
@@ -113,9 +113,9 @@ public function users_can_set_their_password_when_they_have_none_set_yet()
113113
}
114114

115115
/** @test */
116-
public function twitter_handle_is_optional()
116+
public function twitter_is_optional()
117117
{
118-
$user = $this->createUser(['email' => 'freek@example.com', 'username' => 'freekmurze', 'twitter_handle' => 'freek-murze']);
118+
$user = $this->createUser(['email' => 'freek@example.com', 'username' => 'freekmurze', 'twitter' => 'freektwitter']);
119119

120120
$this->loginAs($user);
121121

@@ -124,12 +124,12 @@ public function twitter_handle_is_optional()
124124
'name' => 'Freek Murze',
125125
'email' => 'freek@example.com',
126126
'username' => 'freekmurze',
127-
'twitter_handle' => '',
127+
'twitter' => '',
128128
])
129129
->seePageIs('/settings')
130-
->dontSee('freek-murze');
130+
->dontSee('freektwitter');
131131

132-
$this->assertNull($user->fresh()->twitterHandle());
132+
$this->assertNull($user->fresh()->twitter());
133133
}
134134

135135
private function assertPasswordWasHashedAndSaved(): void

0 commit comments

Comments
 (0)