Add user page.
This commit is contained in:
parent
ecc35c6fe6
commit
2f215d0b82
5 changed files with 81 additions and 0 deletions
18
app/Http/Controllers/UserController.php
Normal file
18
app/Http/Controllers/UserController.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show user page
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
return view('user.show', compact('user'));
|
||||
}
|
||||
}
|
||||
|
|
@ -57,6 +57,15 @@ class User extends Authenticatable
|
|||
return $this->belongsTo(Character::class, 'character_id');
|
||||
}
|
||||
|
||||
public function alt_characters()
|
||||
{
|
||||
$relation = $this->characters();
|
||||
if ($this->character_id) {
|
||||
$relation->where('id', '!=', $this->character_id);
|
||||
}
|
||||
return $relation;
|
||||
}
|
||||
|
||||
public function characters()
|
||||
{
|
||||
return $this->hasMany(Character::class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue