控制器和路由
作业标题:0903作业
作业内容:1.创建相应控制器和路由 2.预习Blade 模板
- 1.创建相应控制器和路由
路由
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//会员操作
//增
//修改
//删除
//查看
//资源路由
//Route::resource('/admin/home/user',\App\Http\Controllers\test\ResourceController::class);
//
// Route::resource('/admin/user',\App\Http\Controllers\test\ResourceController::class)
// ->except([
// 'index',
// 'show',
// 'create'
// ]);
//命名资源路由
// Route::resource('/admin/home/phpcn',\App\Http\Controllers\test\ResourceController::class)
// ->names([
// //方法名=>要更换的路由名称
// 'store'=>'nihao.store'
// ]);
// //补充资源路由
// Route::get('/admin/home/phpcn/sigle/{id?}',[\App\Http\Controllers\test\ResourceController::class,'sigle']);
// //修改命名资源路由的参数名称
// Route::resource('/admin/home/haha',\App\Http\Controllers\test\ResourceController::class)
// ->parameters([
// 'haha'=>'name'
// ]);
//项目后台路由
Route::get('/admin/home/welcome',[\App\Http\Controllers\Admin\IndexController::class,'index'])
->name('admin.index');
//会员资源路由
Route::resource('/admin/home/user',\App\Http\Controllers\Admin\UserController::class);
//会员权限资源路由
Route::resource('/admin/home/purchase',\App\Http\Controllers\Admin\PurchaseController::class)
控制器
```php
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class IndexController extends Controller
{
//
}
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class LoginController extends Controller
{
//
}
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class OrderController extends Controller
{
//
}
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class PurchaseController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($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)
{
//
}
}
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class QuestionController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($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)
{
//
}
}
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class UserController extends Controller
{
//
}
```