0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravelのコントローラー解説(編集中)

Last updated at Posted at 2021-06-06

コントローラとは、

ルーティングからリクエストを受け取り、適切なレスポンスを返すため、各種のデータ処理を行った上でビューに必要な変数を渡す役割を持った物です。


<?php
 
namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
 
class SampleController extends Controller
{
    public function sampleAction(){
        $title = 'コントローラーのアクションを利用';
        return view('samples.blade_example',[
            'title' => $title,
        ]);
    }
}

<?php
 
namespace App\Http\Controllers;
 
use Illuminate\Http\Request;
 
class SingleAction extends Controller
{
    function __invoke(){
        $title = 'シングルアクションのサンプル';
        $description = 'シングルアクションコントローラを利用しています。';
        return view('samples.single_action', [
            'title' => $title,
            'description' => $description,
        ]);
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?