<?php
namespace App\Http\Controllers;
use App\Article;
use App\Tag;
use App\Http\Requests\ArticleRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class ArticleController extends Controller
{
// 略
public function edit(Article $article)
{
//==========ここから追加==========
$tagNames = $article->tags->map(function ($tag) {
return ['text' => $tag->name];
});
//==========ここまで追加==========
//==========ここから削除==========
return view('articles.edit', ['article' => $article]);
//==========ここまで削除==========
//==========ここから追加==========
return view('articles.edit', [
'article' => $article,
'tagNames' => $tagNames,
]);
//==========ここまで追加==========
}
//略
}