Skip to content

Commit

Permalink
Updated assigned and belongs user relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Crampton committed Feb 26, 2015
1 parent 0877c72 commit 17c4d8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
protected $table = 'master';
protected $primaryKey = 'master_id';

public function belongs_to_user()
public function belongs()
{
return User::where('users_id', $this->master_belongs_to_users_fk)->first()->users_username;
// return User::where('users_id', $this->master_belongs_to_users_fk)->first()->users_username;

// return $this->belongsTo('User', 'users_id', 'master_belongs_to_users_fk');
return $this->belongsTo('User', 'master_belongs_to_users_fk', 'users_id');
}

public function assigned_to_user()
public function assigned()
{
return User::where('users_id', $this->master_assigned_to_users_fk)->first()->users_username;
return $this->belongsTo('User', 'master_assigned_to_users_fk', 'users_id');
}

public function category()
Expand Down
4 changes: 2 additions & 2 deletions app/views/tickets/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
@foreach ($all_tickets as $ticket)
<tr>
<td>{{ $ticket->master_id }}</td>
<td>{{ $ticket->belongs_to_user() }}</td>
<td>{{ $ticket->belongs->users_username }}</td>
<td>{{ $ticket->master_description }}</td>
<td>{{ $ticket->category->categories_name }}</td>
<td>{{ $ticket->priority->priorities_name }}</td>
<td>{{ $ticket->assigned_to_user() }}</td>
<td>{{ $ticket->assigned->users_username }}</td>
<td>{{ $ticket->status->statuses_name }}</td>
</tr>
@endforeach
Expand Down

0 comments on commit 17c4d8c

Please sign in to comment.