Move admin controllers to own namespace, and give better method names
This commit is contained in:
parent
6d4c566944
commit
1c8f696024
7 changed files with 144 additions and 137 deletions
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\MicropubClient;
|
||||
|
||||
class ClientsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of known clients.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function listClients()
|
||||
{
|
||||
$clients = MicropubClient::all();
|
||||
|
||||
return view('admin.listclients', ['clients' => $clients]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to add a client name.
|
||||
*
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function newClient()
|
||||
{
|
||||
return view('admin.newclient');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to adda new client name.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function postNewClient(Request $request)
|
||||
{
|
||||
MicropubClient::create([
|
||||
'client_url' => $request->input('client_url'),
|
||||
'client_name' => $request->input('client_name'),
|
||||
]);
|
||||
|
||||
return view('admin.newclientsuccess');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a form to edit a client name.
|
||||
*
|
||||
* @param string The client id
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function editClient($clientId)
|
||||
{
|
||||
$client = MicropubClient::findOrFail($clientId);
|
||||
|
||||
return view('admin.editclient', [
|
||||
'id' => $clientId,
|
||||
'client_url' => $client->client_url,
|
||||
'client_name' => $client->client_name,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param string The client id
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\View\Factory view
|
||||
*/
|
||||
public function postEditClient($clientId, Request $request)
|
||||
{
|
||||
$client = MicropubClient::findOrFail($clientId);
|
||||
if ($request->input('edit')) {
|
||||
$client->client_url = $request->input('client_url');
|
||||
$client->client_name = $request->input('client_name');
|
||||
$client->save();
|
||||
|
||||
return view('admin.editclientsuccess');
|
||||
}
|
||||
if ($request->input('delete')) {
|
||||
$client->delete();
|
||||
|
||||
return view('admin.deleteclientsuccess');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue