Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

php - 在控制器构造函数与表单请求中进行授权(Authorizing in controller constructor vs form request)

什么时候应该在控制器构造授权使用authorizeResource 喜欢这里时,我应该使用中授权表单请求喜欢这里

  ask by Ali translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You authorize a controller when you want to authorize more than one action.

(当您想授权多个动作时,就授权一个控制器。)

The authorizeResource covers multiple actions, while the form request is for the current request only.

(authorizeResource涵盖多个操作,而表单请求仅针对当前请求。)

You could use form request authorization when you would like to authorize only the store and update actions for example, as for those more often a FormRequest is used.

(例如,当您只想对存储和更新操作进行授权时,可以使用表单请求授权,因为更经常使用FormRequest。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...