resource 风格

概念

一种软件架构风格、设计风格,而不是标准,只是提供了一组设计原则和约束条件。它主要用于客户端和服务器交互类的软件。基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制。

URL定义
资源:互联网所有的事物都可以被抽象为资源
资源操作:使用POST、DELETE、PUT、GET,使用不同方法对资源进行操作。
分别对应 添加、 删除、修改、查询

路由:

Route::prefix('api')->group(function ()
{
Route::resource('photo','PhotoController');
});

composer  安装资源路由控制器

php artisan make:controller PhotoController --resource
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PhotoController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
echo "index";
} /**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
echo "create";
} /**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
echo "store";
} /**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
echo 'show'.$id;
} /**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
echo '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)
{
//
echo 'update'.$id;
} /**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
echo 'destroy'.$id;
}
}

最新文章

  1. RadioGroup实现导航栏
  2. paip.自动import的实现跟java.lang.SecurityException Prohibited package name java
  3. 【JAVA】&quot;骗人&quot;的“replaceAll”
  4. 《University Calculus》-chaper13-多重积分-三重积分的引入
  5. 省队集训day6 B
  6. MySQL取得当前时间的函数是什么 格式化日期的函数是什么
  7. mysql_config_editor程序的用法
  8. 在centos上部署java WEB环境
  9. [SCOI 2011]糖果
  10. 2015-11-06 ajax
  11. TestNG 单元测试框架的使用
  12. 利用Linux信号SIGUSR1调试程序
  13. Notepad++ 大小写转换
  14. Word Ladder 有必要深究。非图的广度优先遍历。标记
  15. HTML第二课——css
  16. js中两种定时器的设置及清除
  17. PHP中的递增/递减运算符
  18. asp中将系统货币符号¥改为美国货币符号$的做法
  19. #Spring实战第二章学习笔记————装配Bean
  20. STM32f103的电阻触摸屏的五点校正算法

热门文章

  1. HOOK API(二) —— HOOK自己程序的 MessageBox
  2. 【收藏】Supervisor的作用与配置
  3. 关于unix下cp命令复制权限不够的问题
  4. shell脚本命令(sotr/unip/tr/cut/eval)与正则表达式
  5. java 监听redis事件
  6. Pandas中Series与Dataframe的初始化
  7. Jest_JavaScript测试框架
  8. Solution -「HDU #6566」The Hanged Man
  9. 私有化轻量级持续集成部署方案--03-部署web服务(下)
  10. 带分数--第四届蓝桥杯省赛C++B/C组