use App\Models\Test;
use Illuminate\Support\Facades\DB;// DBを呼び出す
public function index2(Request $request){
}
// index2メソッドに追加
$result=DB::table("tests")->get();
return view('hello2',compact(result));
// compact配列に追加してresultをviewに渡す
@foreach ($result as $value)
<p>{{$value->name}}</p>
@endforeach
// index2メソッドに追加
$resultfind=DB:table("tests")->find(2)
return view('hello2',compact('str',str2',result,resultfind));
// compact配列に追加してresultfindをviewに渡す
<p>{{$resultfind->name}}</p>
// index2メソッドに追加
$resultwhere=DB::table("tests")->where('sei','=',1)->get();
return view('hello2',compact('str',str2',result,resultfind,resultwhere));
// compact配列に追加してresultwhereをviewに渡す
@foreach ($resultwhere as $value)
<p>{{$value->name}}</p>
@endforeach