Skip to content

Commit 471c31b

Browse files
committed
route + profile
1 parent 15cbb2a commit 471c31b

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

app/Http/Controllers/ProfileController.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,27 @@
33
namespace App\Http\Controllers;
44

55
use Illuminate\Http\Request;
6-
6+
use Illuminate\Support\Facades\DB;
7+
use Illuminate\Support\Facades\Auth;
78
class ProfileController extends Controller
89
{
910
public function index(){
10-
return view('profile');
11+
if (Auth::user())
12+
{
13+
$name=Auth::user()->username;
14+
$user=DB::table('users')
15+
->join('posts', 'users.id', '=', 'posts.user_id')
16+
->join('tempat_wisatas', 'tempat_wisatas.id', '=', 'posts.wisata_id')
17+
->join('kategoris','kategoris.id','=','tempat_wisatas.id_kategori')
18+
->join('kotas','kotas.id','=','tempat_wisatas.id_kota')
19+
->select('users.name','posts.*','kategoris.*','kotas.*','tempat_wisatas.*')
20+
->where('users.name','=',$name)
21+
->get();
22+
23+
$count=DB::table('users')
24+
->join('posts', 'users.id', '=', 'posts.user_id')
25+
->count()->get();
26+
return view('profile', compact('user','count'));
27+
}
1128
}
1229
}

resources/views/layouts/profile.blade.php resources/views/profile.blade.php

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2+
@foreach($user as $a)
3+
<p>{{$a->name}}</p><br>
4+
<p>{{$a->email}}</p><br>
5+
@endforeach
6+
7+
8+
9+
10+
11+
12+
13+
114
<!DOCTYPE html>
215
<html>
316
<head>

routes/web.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
Auth::routes();
2020
Route::get('/home', 'HomeController@index')->name('home');
21-
Route::get('/profile', 'PostController@index');
21+
Route::get('/profile', 'ProfileController@index');
2222
Route::get('/comment', 'CommentController@index');
2323

2424
Auth::routes();

0 commit comments

Comments
 (0)