Skip to content

Commit 9d11134

Browse files
committed
change users.first_name and users.last_name to just users.name
1 parent 5996a2a commit 9d11134

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

src/Cmgmyr/Messenger/Models/Thread.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function activateAllParticipants()
205205
* @param array $columns
206206
* @return string
207207
*/
208-
public function participantsString($userId=null, $columns=['first_name', 'last_name'])
208+
public function participantsString($userId=null, $columns=['name'])
209209
{
210210
$selectString = $this->createSelectString($columns);
211211

src/Cmgmyr/Messenger/examples/create_users_table.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public function up()
1414
{
1515
Schema::create('users', function (Blueprint $table) {
1616
$table->increments('id')->unsigned();
17-
$table->string('first_name');
18-
$table->string('last_name');
17+
$table->string('name');
1918
$table->string('email')->unique();
2019
$table->enum('notify', ['y', 'n'])->default('y');
2120
$table->timestamps();

src/Cmgmyr/Messenger/examples/views/create.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@if($users->count() > 0)
2020
<div class="checkbox">
2121
@foreach($users as $user)
22-
<label title="{{$user->first_name}} {{$user->last_name}}"><input type="checkbox" name="recipients[]" value="{{$user->id}}">{{$user->first_name}}</label>
22+
<label title="{{$user->name}}"><input type="checkbox" name="recipients[]" value="{{$user->id}}">{{$user->name}}</label>
2323
@endforeach
2424
</div>
2525
@endif

src/Cmgmyr/Messenger/examples/views/show.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
@foreach($thread->messages as $message)
88
<div class="media">
99
<a class="pull-left" href="#">
10-
<img src="//www.gravatar.com/avatar/{{$message->user->email}}?s=64" alt="{{$message->user->first_name}}" class="img-circle">
10+
<img src="//www.gravatar.com/avatar/{{$message->user->email}}?s=64" alt="{{$message->user->name}}" class="img-circle">
1111
</a>
1212
<div class="media-body">
13-
<h5 class="media-heading">{{$message->user->first_name}} {{$message->user->last_name}}</h5>
13+
<h5 class="media-heading">{{$message->user->name}}</h5>
1414
<p>{{$message->body}}</p>
1515
<div class="text-muted"><small>Posted {{$message->created_at->diffForHumans()}}</small></div>
1616
</div>
@@ -27,7 +27,7 @@
2727
@if($users->count() > 0)
2828
<div class="checkbox">
2929
@foreach($users as $user)
30-
<label title="{{$user->first_name}} {{$user->last_name}}"><input type="checkbox" name="recipients[]" value="{{$user->id}}">{{$user->first_name}}</label>
30+
<label title="{{$user->name}}"><input type="checkbox" name="recipients[]" value="{{$user->id}}">{{$user->name}}</label>
3131
@endforeach
3232
</div>
3333
@endif

tests/EloquentThreadTest.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,9 @@ public function it_should_generate_participant_select_string()
222222
$select = $method->invokeArgs($thread, [$columns]);
223223
$this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.name) as name", $select);
224224

225-
$columns = ['first_name', 'last_name'];
225+
$columns = ['name', 'email'];
226226
$select = $method->invokeArgs($thread, [$columns]);
227-
$this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.first_name || ' ' || " . Eloquent::getConnectionResolver()->getTablePrefix() . "users.last_name) as name", $select);
228-
229-
$columns = ['first_name', 'last_name', 'email'];
230-
$select = $method->invokeArgs($thread, [$columns]);
231-
$this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.first_name || ' ' || " . Eloquent::getConnectionResolver()->getTablePrefix() . "users.last_name || ' ' || " . Eloquent::getConnectionResolver()->getTablePrefix() . "users.email) as name", $select);
227+
$this->assertEquals("(" . Eloquent::getConnectionResolver()->getTablePrefix() . "users.name || ' ' || " . Eloquent::getConnectionResolver()->getTablePrefix() . "users.email) as name", $select);
232228
}
233229

234230
/** @test */
@@ -248,7 +244,7 @@ public function it_should_get_participants_string()
248244
$string = $thread->participantsString(1);
249245
$this->assertEquals("Adam Wathan, Taylor Otwell", $string);
250246

251-
$string = $thread->participantsString(1, ['first_name']);
252-
$this->assertEquals("Adam, Taylor", $string);
247+
$string = $thread->participantsString(1, ['email']);
248+
$this->assertEquals("[email protected], [email protected]", $string);
253249
}
254250
}

tests/MessagableTraitTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public function it_should_get_all_threads_with_new_messages()
1717
{
1818
$user = User::create(
1919
[
20-
'first_name' => 'John',
21-
'last_name' => 'Doe',
20+
'name' => 'John Doe',
2221
'email' => '[email protected]',
2322
'notify' => 'y'
2423
]
@@ -53,5 +52,5 @@ class User extends Eloquent
5352

5453
protected $table = 'users';
5554

56-
protected $fillable = ['first_name', 'last_name', 'email', 'notify'];
55+
protected $fillable = ['name', 'email', 'notify'];
5756
}

tests/TestCase.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ private function createUsersTable()
6868
'users',
6969
function ($table) {
7070
$table->increments('id');
71-
$table->string('first_name');
72-
$table->string('last_name');
71+
$table->string('name');
7372
$table->string('email')->unique();
7473
$table->enum('notify', ['y', 'n'])->default('y');
7574
$table->timestamps();
@@ -82,9 +81,9 @@ function ($table) {
8281
*/
8382
private function seedUsersTable()
8483
{
85-
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, first_name, last_name, email, created_at, updated_at) VALUES (?, ?, ?, ?, datetime(), datetime())', [1, 'Chris', 'Gmyr', '[email protected]']);
86-
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, first_name, last_name, email, created_at, updated_at) VALUES (?, ?, ?, ?, datetime(), datetime())', [2, 'Adam', 'Wathan', '[email protected]']);
87-
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, first_name, last_name, email, created_at, updated_at) VALUES (?, ?, ?, ?, datetime(), datetime())', [3, 'Taylor', 'Otwell', '[email protected]']);
84+
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [1, 'Chris Gmyr', '[email protected]']);
85+
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [2, 'Adam Wathan', '[email protected]']);
86+
DB::insert('INSERT INTO ' . DB::getTablePrefix() . 'users (id, name, email, created_at, updated_at) VALUES (?, ?, ?, datetime(), datetime())', [3, 'Taylor Otwell', '[email protected]']);
8887
}
8988

9089
/**

0 commit comments

Comments
 (0)