備忘録です。
複数アクションの利用
複数アクション
複数アクションを利用することもできる。
Controllerとweb.phpのみで一例を挙げる。
下記の例の場合、indexというページとotherというページが存在し、それぞれのページ上に存在するリンクを押下することで、相互のページに行き来することができる。
一例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; global $head, $style, $body, $end; $head = '<html><head>'; $style = <<<EOF <style> body { font-size:16pt; color:#999; } h1 { font-size:100pt; text-align:right; color:#eee; margin:-40px 0px -50px 0px; } </style> EOF; $body = '</head><body>'; $end = '</body></html>'; // タグ付け function tag($tag, $txt) { return "<{$tag}>" . $txt . "</{$tag}>"; } class HelloController extends Controller { public function index() { global $head, $style, $body, $end; $html = $head . tag('title', 'Hello/Index') . $style . $body . tag('h1', 'Index') . tag('p', 'this is Index page') . '<a href="/hello/other">go to <b>other</b> page</a>' . $end; return $html; } public function other() { global $head, $style, $body, $end; $html = $head . tag('title', 'Hello/other') . $style . $body . tag('h1', 'other') . tag('p', 'this is other page') . '<a href="/hello">go to <b>index</b> page</a>' . $end; return $html; } } |
1 2 |
Route::get('hello', 'HelloController@index'); Route::get('hello/other', 'HelloController@other'); |
参照
『Laravel入門』(掌田津耶乃)
Laravelを効率的に学習したい場合
スクールを活用するのも有効

Laravelを効率的に学習したい場合、スクールを活用するのも有効です。
転職を視野に入れている方、将来に向けて学習を進めている学生の方など、良かったら説明を聴いてみてはいかがでしょうか(説明会の参加は無料です)。
他のスクールについては下記の記事にまとめてあります。他のスクールについても視野に入れたい場合、参考になるかと思います。

【プログラミング】スクール一覧プログラミングのスクールで学ぶことを視野に入れた方向けに、ご紹介します。
転職を視野に入れたい
新卒で入社を視野に入れた...
ダイス
ご参考になれば幸いです。