资源路由
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Student;
use Illuminate\Http\Request;
use App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\view\ViewServiceProvider;
class PhotoController2 extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// $students=Student::$students;
// $id=null;
// $xingming =null;
// $xh = null;
// $zhuanye=null;
// $xingbie=null;
// $banji=null;
// $data = compact('students','id','xingming','xh','zhuanye','xingbie','banji');
// return view('info',$data);
//
$users = DB::table('users')->get();
dd($users);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
// dd('create');
// $message="信息正确";
// return view('create',compact('message'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
// dd($request->all());
// $data=$request->except("_token");
// return view('store',compact('data'));
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$user=DB::table('users')->where('id',$id)->first();
dd($user);
// $stu=null;
// $students=Student::$students;
// foreach($students as $value){
// if($value['xh']==$id){
// $stu=$value;
// }
}
// return view('detail',compact('stu'));
// 老师讲的方法一:dd('show:'.$id);
// return view('info',['id'=>$id]);
// 老师讲的方法二:$data=['id'=>$id,'name'=>'张三'];
// return view('info')->with('id',$id)
// ->with(compact('data','id'));
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
// return view('edit',compact('id')); //
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
}
public function login(){
return view('login');
}
// public function showSome(){
// $namea='老师';
// return view('admin.login')
// ->with('name',$namea)
// ->with('age',31);
// }
public function loginCheck(Request $request){
$data=$request->all();
$username=$request->input('username');
$password=$request->input('password');
// dd($data,$username);
$res=DB::table('users')->where('name',$username)
->where('password',$password)
->first();
if($res==null){
echo '<script language="JavaScript"> alert("登录失败"); </script>';
}
else{
echo '<script language="JavaScript"> alert("用户名及密码正确"); </script>';
}
dd($res);
}
}
|