namespace App\Http\Controllers;
// 記事用とバイナリファイル用のモデルを呼び出し
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class BbsController extends Controller
public function index(Request $request)
$post_list = Posting::query()->where('target_id',0)->orderBy('id','desc')->paginate(5);
$post_list->setPath('/index');
return view('index',compact(
public function editPage(Request $request)
$id = $request->input('number');
$target_post = Posting::query()->where('id',$id)->first();
return view('editPage',compact(
public function deletePage(Request $request)
$id = $request->input('number');
$target_post = Posting::query()->where('id',$id)->first();
return view('deletePage',compact(
public function replyPage(Request $request)
$id = $request->input('number');
$target_post = Posting::query()->where('id',$id)->first();
return view('replyPage',compact(
public function resultPage()
// 処理時にセッションに保存された成功メッセージを取得
$success_msg = session()->pull('success_msg');
return view('resultPage',compact(
public function list(Request $request)
$id = $request->input('number');
$target_post = Posting::query()->where('id',$id)->first();
$post_list = Posting::query()->where('target_id',$id)->orderBy('id','desc')->paginate(5);
$post_list->setPath('/list?number=');
return view('list',compact(
public function loadFile(Request $request)
$id = $request->input('number');
$file = UploadFile::query()->where('id',$id)->first();
// もし対象記事に関連するバイナリファイルがあれば
header("Content-Type: ".$file->mime);
return redirect()->back();