โง '๋ฉ๋ฉํ์ ๋ผ๋ผ๋ฒจ๋ก ์๋ก ๋ง๋ค๊ธฐ' ํ๋ก์ ํธ ๋ชฉ์ฐจ โง (๋ณด์๋ ค๋ฉด ์๋ ๋๋ณด๊ธฐ ๋ฅผ ๋๋ฌ์ฃผ์ธ์.)
0. ๋ผ๋ผ๋ฒจ(laravel) ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ถํ๊ธฐ-๋ฐฉ๋ฒ2 (Windows & ๋์ปค(docker) & sail ํ์ฉ)
2. ๊ธฐ์กด ์์ค๋ฅผ ํ๋์ ๋ธ๋ ์ด๋๋ก
5. ๊ธฐ์กด PHP ๋ก์ง์ ์ปจํธ๋กค๋ฌ๋ก
6. ๋ธ๋ ์ด๋ ๋ฌธ๋ฒ์ผ๋ก ์์
7. ์ธ๋ถ ๋ธ๋ ์ด๋ ํ์ผ, component ํ์ฉ
8. (DB) Model ๋ฐ ๊ธฐํ ํ์ผ ์์ฑ
9. (DB) ๋๋ฏธ๋ฐ์ดํฐ๋ฅผ ํ๊ธ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ
10. (DB) ๋ชจ๋ธ, DB ํ์ฉ ์ฐ์ต
11. (DB) ๊ธฐ์กด ๋ฐ์ดํฐ ๋ฐฐ์ด์ DB๋ก ๋ณํ
12. (DB) DB ๋ฐ ๋ชจ๋ธ์ ์ด์ฉํ์ฌ ๊ตฌํ
13. ๋ก๊ทธ์ธ ๊ตฌํ์ ์ํ ์คํํฐํคํธ Breeze ์ค์น ๋ฐ ๋ก๊ทธ์ธ ์์
14. ๋ก๊ทธ์ธ ์ฐฝ ๋ท๋ฐฐ๊ฒฝ๋ ๋์์์ด ๋ณด์ด๋๋ก ์์
15. ๊ด๋ฆฌ์ ํ๋ฉด์์ ์ ์ฒด ๊ฒ์๊ธ ๋ฆฌ์คํธ ํ๋ฒ์ ๋ณด๊ธฐ
16. ๊ด๋ฆฌ์ ํ๋ฉด์์ ๊ฒ์๊ธ ์์ ํ๊ธฐ
17. ๊ด๋ฆฌ์ ํ๋ฉด์์ ๊ฒ์๊ธ ์ญ์ ํ๊ธฐ
๋ก๊ทธ์ธ ์ฐฝ์ ๋ฌ๊ณ ๋๋ ๋ก๊ทธ์ธ ์ฐฝ ๋ท๋ฐฐ๊ฒฝ์๋ ๋์์์ด ๋ณด์ด๊ฒ ํ๋ ๊ฒ์ด ๊ฐ๋ฅํ ์ง ๊ถ๊ธํด์ก์ต๋๋ค.
๊ทธ๋์ ํ๋ฒ ์๋๋ฅผ ํด๋ด ๋๋ค. ๋ค๋ง, ์ด๋ ๊ฒ ํ๋ฉด์ ์ ๊ฐ ๋ณด์์ ์๋ชป ๊ฑด๋๋ฆฌ๊ณ ์๋ ๊ฒ์ด ์๋์ง๋ ์์ง ์ค๋ ฅ์ด ๋ถ์กฑํ ์ ๋ก์๋ ์ ๋ชจ๋ฅด๋ ์ฐ์ ์ ๊ณต๋ถ์ฉ์ผ๋ก ์ฐธ๊ณ ๋ฐ๋๋๋ค. ^^;
์ฐ์ ๊ธฐ์กด ํ์ผ ๊ตฌ์ฑ์ด ์กฐ๊ธ ํท๊ฐ๋ ค์ ํ์ผ๋ค์ ๋ชจ๋ ์ ๋ฆฌ๋ฅผ ํ๊ณ ๋ผ์ฐํธ๋ ์์ ์ ํ์ฌ, ์๋์ ๊ฐ์ด ์ ๋ฆฌ๋ฅผ ํ์์ต๋๋ค. (ํ์ผ ์ด๋ฆ๋ฟ ์๋๋ผ, ๊ฐ ํ์ผ ๋ด๋ถ์ ์๋ ๊ฒ๋ค๋ ์์ ์ ํด์ฃผ์ด์ผ๋ง ํฉ๋๋ค.)
< DB, ๋ชจ๋ธ ์ด์ฉ ๋ฐฉ๋ฒ > | < ๊ธฐ์กด ๋ฐฐ์ด ๋ฐฉ๋ฒ(๋ณด๊ด์ฉ) > | |||||||
Route::get('/', [IndexController::class, 'index']); | ๋ผ์ฐํธ | Route::get('/view', [PostController::class, 'index']); | ||||||
IndexController | ์ปจํธ๋กค๋ฌ | PostController | ||||||
index.blade.php components/layerhelps.blade.php components/newpanel.blade.php components/panes.blade.php |
๋ทฐ | index2.blade.php layerhelps2.blade.php components/newpanel2.blade.php components/panes2.blade.php |
||||||
header.blade.php | ๊ณตํต | header.blade.php |
์ ์ฒ๋ผ ํ์ผ ์ด๋ฆ๋ค์ ๋ฐ๊พธ๋ ์์ ์ด ์ค๋ฅ๊ฐ ๋ง์ด ์๊ธฐ๊ณ ๊ท์ฐฎ๊ธฐ๋ ํ์ง๋ง, ํ๋ํ๋ ์ก์๋ด๋ฉด์ ๋ํ๋ฒ ๊ณต๋ถ๋ฅผ ํด๋ณผ ์ ์๋ ๊ธฐํ๊ฐ ๋๋ค์.
1. index.blade.php ์์
๊ฐ. index ํ์ผ์์ ํต์ฌ์ด ๋๋ ๋ด์ฉ์ ์ ์ธํ๊ณ , ๋ค๋ฅธ ํ์ผ(๋ก๊ทธ์ธ ํ์ผ)์์๋ ๊ณตํต์ ์ผ๋ก ์ฌ์ฉํ ์ ์๋ ์๋ถ๋ถ(๋ณธ ๋ด์ฉ์์๋ ์ฒซ์ค๋ถํฐ ์ ํ๋ธ ์์ ๋ณด์ฌ์ฃผ๋ ๋ถ๋ถ๊น์ง๋ง...)๊ณผ ๋ท๋ถ๋ถ์ ๋ถ๋ฆฌํ ๋ค์ ๋ณ๋์ ํ์ผ๋ก ๋ณต์ฌ๋ฅผ ํด์ค๋๋ค. ์ฌ๊ธฐ์๋ components/topframe.blade.php ํ์ผ์ ์์ฑ ํ ์๋์ฒ๋ผ ์์ค๋ฅผ ์ ๋ฆฌํฉ๋๋ค.
< ๊ธฐ์กด index.blade.php > | < ์์ index.blade.php > |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>๐พ์ ๋ฉ๋ฉ์ค ํ</title>
<link href="/css/app.css" rel="stylesheet">
<script src='http://code.jquery.com/jquery-latest.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.mb.YTPlayer/3.3.9/jquery.mb.YTPlayer.min.js'></script>
<script src="/js/app.js"></script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<div id="background" class="player"
data-property="{
videoURL: '{{ $select_movie }}',
mute: true,
showControls: false,
useOnMobile: true,
quality: 'highres',
containment: 'body',
loop: true,
autoPlay: true,
stopMovieOnBlur: false,
startAt: 0,
opacity: 1
}">
</div>
@include('header')
~~~~~~~~~~~~~~~~~์ค๊ฐ ์๋ต~~~~~~~~~~~~~~~~~~~~
@endfor
<p align=center> </p>
<p align=center> </p>
<p align=center> </p>
</body>
</html>
|
<x-topframe :select_movie="$select_movie"> @include('header') ~~~~~~~~~~~~~~~~~์ค๊ฐ ์๋ต~~~~~~~~~~~~~~~~~~~~ @endfor
</x-topframe> |
๋. ๊ณตํต์ ์ผ๋ก ์ฌ์ฉํ components/topframe.blade.php ํ์ผ ๋ด์ฉ
- ๋งจ ์์ @props(['select_movie']) ์ถ๊ฐ
- ์ค๊ฐ์ {{ $slot }} ์ถ๊ฐ
@props(['select_movie'])
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
~~~~~~~~~~~~~~~~~์ค๊ฐ ์๋ต~~~~~~~~~~~~~~~~~~~~
opacity: 1
}">
</div>
{{ $slot }}
<p align=center> </p>
<p align=center> </p>
<p align=center> </p>
</body>
</html>
์ด๋ ๊ฒ ํด๋ ์ ์์ ์ผ๋ก ํํ์ด์ง๊ฐ ๋ณด์ผ ๊ฒ์ ๋๋ค.
2. views/auth/login.blade.php ์์
๊ฐ. http://127.0.0.1/login ์์ ๋ณด์ฌ์ง๋ ํ๋ฉด์ views/auth/login.blade.php ์ ์ ์๋์ด ์์ต๋๋ค.
<x-guest-layout>
<x-auth-card>
<x-slot name="logo">
<a href="/">
~~~~~~~~~ ์ค๊ฐ ์๋ต ~~~~~~~~~~~~~~~~~~~~
</div>
</form>
</x-auth-card>
</x-guest-layout>
๋. ์์์ ๋ณด๋ฉด ์ํ๋จ ๋์ด <x-guest-layout>~~</x-guest-layout>๋ก ๋๋ฌ์์ฌ ์์ต๋๋ค. ์ด ๋ถ๋ถ์ ์๊น ๋ง๋ค์ด ๋์๋ <x-topframe>~</x-topframe>๋ก ๊ต์ฒดํด์ค๋๋ค. ๋ํ, ์์ ์ฃผ์๋ฅผ ๋ณ์๋ก ๋ฐ๊ธฐ ์ํด select_movie="$select_movie"๋ถ๋ถ๋ ๋ฃ์ด์ฃผ์ด์ผ ํฉ๋๋ค.
<x-topframe :select_movie="$select_movie">
<x-auth-card>
<x-slot name="logo">
<a href="/">
~~~~~~~~~ ์ค๊ฐ ์๋ต ~~~~~~~~~~~~~~~~~~~~
</div>
</form>
</x-auth-card>
</x-topframe>
์!!! ์ด๋ ๊ฒ ํ๋๋ฐ $select_movie ๋ณ์ ๋๋ฌธ์ ์ค๋ฅ๊ฐ ๋๋ค์. ์ ๋๋ก ์ ๋ฌ์ด ๋์ง๋ฅผ ์๋ค์. ์์ธ์ ์ฐพ์๋ณด์์ต๋๋ค.
Route::get('/', [IndexController::class, 'index']);
Route::get('/view', [PostController::class, 'index']);
Route::get('/view2', function () {
return view('welcome');
});
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
require __DIR__.'/auth.php';
web.php ํ์ผ์ ๋ณด๋ /login ์ ๋ํ ๋ผ์ฐํธ ๋ด์ฉ์ ๋ณด์ด์ง๋ฅผ ์๋ค์. ํ์ง๋ง ๋ง์ง๋ง ์๋ก ์๊ธด require __DIR__.'/auth.php'; ๋ถ๋ถ์ ๋ณด๋ ์ธ๋ถ ํ์ผ์ ๋ถ๋ฌ์ค๋ค์. ๊ฐ์ routes ํด๋ ๋ด์ auth.php ํ์ผ์ ๋ถ๋ฌ์ค๋ ๊ฒ์ด๋ค์.
์์ฒญ ๋ณต์กํ ํ์ผ์ด๋ค์.
์ด์ค, login ๋ถ๋ถ์ ๋ณด๋ AuthenticatedSessionController ์ปจํธ๋กค๋ฌ์ 'create' ํจ์๋ฅผ ์ฌ์ฉํฉ๋๋ค.
app/Http/Controllers/Auth/AuthenticatedSessionController.php์ ์ด์ด์ create ํจ์๋ฅผ ์๋์ ๊ฐ์ด ์์ ํฉ๋๋ค.
public function create()
{
$arr_movie = array(
"https://youtu.be/KmafPs7Ljxw",
"https://youtu.be/HrmWAdF_s6Y",
"https://youtu.be/Dw1BhP7WJbo",
"https://youtu.be/0snKAXOdY20",
"https://youtu.be/_y8Rg4hgF1k",
"https://youtu.be/vqT7ADQmZ7o",
"https://youtu.be/10X1siLTuac",
"https://youtu.be/3sE_YweJ4E4",
"https://youtu.be/rsUnpWA_kRw",
"https://youtu.be/YAyfr_mR9rk",
);
$select_index_movie = array_rand($arr_movie);
$select_movie = $arr_movie[$select_index_movie];
return view('auth.login', [
'select_movie' => $select_movie,
]);
}
3. IndexController์ AuthenticatedSessionController ์ค๋ณต ์ ๊ฑฐ
์ ์ ํ๋ธ ์ฃผ์ ๋๋ค ๋ฝ๋ ๋ถ๋ถ์ด IndexController์ AuthenticatedSessionController ์ ์ค๋ณต๋์ด ๋ค์ด๊ฐ๋ค์. ์ด ์ค๋ณต์ ํด๊ฒฐํ๊ธฐ ์ํด ๋ํ๋ฒ ๋์ ํด ๋ด ๋๋ค.
๊ฐ. ๋จผ์ IndexController์ ์๋ ์ ํ๋ธ ๊ด๋ จ ์ฝ๋ ๋ถ๋ถ์ ๋นผ์ ๋ณ๋์ ํจ์๋ก ๋ง๋ค๊ณ , ์์๋ฆฌ์ $select_movie = youtube(); ๋ผ๊ณ ๋ฃ์๋๋ ์ค๋ฅ๊ฐ ๋จ๋ค์. ๊ฐ์ ํด๋์ค ์์ ์๋ ํจ์์ธ๋ฐ๋, ํด๋์ค ๋ช ์ ๊ผญ ๋ถ์ฌ์ฃผ์ด์ผ ํ๋๊ฐ ๋ด ๋๋ค. (์ ๊ฐ class์ ๋ํด ์ ๋๋ก ๊ณต๋ถํด๋ณธ ์ ์ด ์์ต๋๋ค.)
๋ ํ๊ฐ์ง. ํจ์๋ช ์ static ๋ฅผ ๊ผญ ๋ถ์ด์ฃผ์ด์ผ ํ๋ค์. ์ธ์คํด์ค๋ฅผ ์์ฑํ์ง ์๊ณ , ํด๋์ค์ ์๋ ํจ์๋ฅผ ์ง์ ์ฐ๊ธฐ ์ํด์๋ static๋ฅผ ๋ถ์ฌ์ฃผ์ด์ผ ํ๋ค๋ ์ด์ผ๊ธฐ๋ ๋ค์ด๋ณธ ์ ์์ต๋๋ค. ^^;
public static function youtube() {
$arr_movie = array(
"https://youtu.be/KmafPs7Ljxw",
"https://youtu.be/HrmWAdF_s6Y",
"https://youtu.be/Dw1BhP7WJbo",
"https://youtu.be/0snKAXOdY20",
"https://youtu.be/_y8Rg4hgF1k",
"https://youtu.be/vqT7ADQmZ7o",
"https://youtu.be/10X1siLTuac",
"https://youtu.be/3sE_YweJ4E4",
"https://youtu.be/rsUnpWA_kRw",
"https://youtu.be/YAyfr_mR9rk",
);
$select_index_movie = array_rand($arr_movie);
return $arr_movie[$select_index_movie];
}
public function index()
{
$select_movie = IndexController::youtube();
$categories = Category::all();
$posts = Post::all();
๋. ์ด์ AuthenticatedSessionController๋ฅผ ์์ ํด ์ค๋๋ค. ๋จ, IndexController์ ์๋ ํจ์๋ฅผ ์ฐ๊ธฐ ์ํด์๋ ๋งจ ์์ค์ use App\Http\Controllers\IndexController; ๋ ์ถ๊ฐํด ์ฃผ์ด์ผ ํฉ๋๋ค.
//๋งจ ์์ค์ ์ถ๊ฐ
use App\Http\Controllers\IndexController;
//create() ํจ์ ์์
public function create()
{
$select_movie = IndexController::youtube();
return view('auth.login', [
'select_movie' => $select_movie,
]);
}
4. login.blade.php์ css ์์
์ฑ๊ณตํ๋ค ์๊ฐํ๊ณ ์๋ก๊ณ ์นจ์ ํ๋ ํ์ ํ๋ฉด์ด ๊ฐ๋ฆฌ๊ณ ์๋ค์. login.blade.php ํ์ผ์ ๋ณด๋, ๋ก๊ทธ์ธ ํ๋ฉด์ auth-card๋ผ๋ ๋ธ๋ ์ด๋ ํ์ผ์ด ๋ ๊ฐ์ธ๊ณ ์๋ค์.
๊ทธ๋์ auth-card.blade.php๋ก ์ด๋ํ์ฌ ์๋ ๋นจ๊ฐ์ ๋ถ๋ถ์ ์ง์๋ฒ๋ฆฝ๋๋ค.
์ด์ ํ๋ฉด์ด ์ํ๋ ๋๋ก ์ ๋๋ก ๋ณด์ ๋๋ค. ์ฑ๊ณต!!!
๐บ๐บ ์์ ํ ๋ชจ๋ ์์ค๋ ์๋ ๋งํฌ์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐บ๐บ
https://github.com/mmssem/munghome
GitHub - mmssem/munghome
Contribute to mmssem/munghome development by creating an account on GitHub.
github.com