优化代码
This commit is contained in:
parent
3fed82ba49
commit
803cb019b2
@ -25,14 +25,13 @@ public function index(): View
|
|||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): View
|
public function store(Request $request): View
|
||||||
{
|
{
|
||||||
//
|
$request->validate([
|
||||||
|
|
||||||
$this->validate($request, [
|
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'description' => 'required',
|
'description' => 'required',
|
||||||
'api_token' => 'required|unique:applications,api_token',
|
'api_token' => 'required|unique:applications,api_token',
|
||||||
@ -50,52 +49,47 @@ public function store(Request $request): View
|
|||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
return view('admin.applications.create');
|
return view('admin.applications.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function show(Application $application): RedirectResponse
|
public function show(Application $application): RedirectResponse
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
return redirect()->route('admin.applications.edit', $application);
|
return redirect()->route('admin.applications.edit', $application);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Application $application): View
|
public function edit(Application $application): View
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
return view('admin.applications.edit', compact('application'));
|
return view('admin.applications.edit', compact('application'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Application $application): RedirectResponse
|
public function update(Request $request, Application $application): RedirectResponse
|
||||||
{
|
{
|
||||||
//
|
$request->validate([
|
||||||
|
|
||||||
$this->validate($request, [
|
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'description' => 'required',
|
'description' => 'required',
|
||||||
'api_token' => 'required|unique:applications,api_token,'.$application->id,
|
'api_token' => 'required|unique:applications,api_token,' . $application->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$application->update($request->all());
|
$application->update($request->all());
|
||||||
@ -106,13 +100,12 @@ public function update(Request $request, Application $application): RedirectResp
|
|||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Application $application): RedirectResponse
|
public function destroy(Application $application): RedirectResponse
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
$application->delete();
|
$application->delete();
|
||||||
|
|
||||||
return redirect()->route('admin.applications.index')->with('success', '应用程序已删除。');
|
return redirect()->route('admin.applications.index')->with('success', '应用程序已删除。');
|
||||||
|
Loading…
Reference in New Issue
Block a user