Skip to content

Instantly share code, notes, and snippets.

@tmf16
Last active December 20, 2018 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmf16/3b4218fb4e01853858cf8c8e3a299f07 to your computer and use it in GitHub Desktop.
Save tmf16/3b4218fb4e01853858cf8c8e3a299f07 to your computer and use it in GitHub Desktop.
test

問題

とあるフレームワークで作られたサービスがあります。 訳あって、ユーザ情報をcsvで管理しています。 ユーザ情報を扱うクラスを作成して、jsonを返却して下さい。

    • ネットで検索してokです
    • 実行環境は無いのでsyntax error等は気にしないでよい

/tmp/users.csv

id,名前,年齢

内容

1, 青木, 36
2, 長山, 30
3, 熊谷, 30
class UserController extends Controller
{
private const USER_PATH = "/tmp/users.csv";
/*
* $user_idに対応するユーザデータをjsonで返す
*/
public function show(int $user_id)
{
$user = null; // ここで作成したクラスのメソッドを呼ぶ
return response()->json(['user' => $user]);
}
/*
* $ageに対応するユーザの一覧をjsonで返す
*/
public function filter(int $age)
{
$users = null; // ここで作成したクラスのメソッドを呼ぶ
return response()->json(['users' => $users]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment