Allow syndication targets to be added/edited in admin interface
This commit is contained in:
parent
ea8395a651
commit
0ddec78d09
7 changed files with 251 additions and 0 deletions
99
app/Http/Controllers/Admin/SyndicationTargetsController.php
Normal file
99
app/Http/Controllers/Admin/SyndicationTargetsController.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SyndicationTarget;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SyndicationTargetsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of known syndication targets.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$targets = SyndicationTarget::all();
|
||||
|
||||
return view('admin.syndication.index', compact('targets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to add a syndication target.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.syndication.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to adda new syndication target.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'uid' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
]);
|
||||
|
||||
SyndicationTarget::create($validated);
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a form to edit a syndication target.
|
||||
*
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return View
|
||||
*/
|
||||
public function edit(SyndicationTarget $syndicationTarget): View
|
||||
{
|
||||
return view('admin.syndication.edit', [
|
||||
'syndication_target' => $syndicationTarget,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(Request $request, SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'uid' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
]);
|
||||
|
||||
$syndicationTarget->update($validated);
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to delete a client.
|
||||
*
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
$syndicationTarget->delete();
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
}
|
|
@ -12,6 +12,22 @@ class SyndicationTarget extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'name',
|
||||
'service_name',
|
||||
'service_url',
|
||||
'service_photo',
|
||||
'user_name',
|
||||
'user_url',
|
||||
'user_photo',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are visible when serializing the model.
|
||||
*
|
||||
|
|
45
resources/views/admin/syndication/create.blade.php
Normal file
45
resources/views/admin/syndication/create.blade.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
@extends('master')
|
||||
|
||||
@section('title')New Syndication Target « Admin CP « @stop
|
||||
|
||||
@section('content')
|
||||
<h1>New Syndication Target</h1>
|
||||
<form action="/admin/syndication" method="post" accept-charset="utf-8" class="admin-form form">
|
||||
{{ csrf_field() }}
|
||||
<div>
|
||||
<label for="uid">Target UID:</label>
|
||||
<input type="text" name="uid" id="uid" placeholder="https://myfavoritesocialnetwork.example/aaronpk">
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Target Name:</label>
|
||||
<input type="text" name="name" id="name" placeholder="aaronpk on myfavoritesocialnetwork">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_name">Service Name:</label>
|
||||
<input type="text" name="service_name" id="service_name" placeholder="My Favorite Social Network">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_url">Service URL:</label>
|
||||
<input type="text" name="service_url" id="service_url" placeholder="https://myfavoritesocialnetwork.example/">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_photo">Service Logo:</label>
|
||||
<input type="text" name="service_photo" id="service_photo" placeholder="https://myfavoritesocialnetwork.example/img/icon.png">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_name">User Name:</label>
|
||||
<input type="text" name="user_name" id="user_name" placeholder="aaronpk">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_url">User URL:</label>
|
||||
<input type="text" name="user_url" id="user_url" placeholder="https://myfavoritesocialnetwork.example/aaronpk">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_photo">User Photo:</label>
|
||||
<input type="text" name="user_photo" id="user_photo" placeholder="https://myfavoritesocialnetwork.example/aaronpk/photo.jpg">
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" name="submit">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
@stop
|
52
resources/views/admin/syndication/edit.blade.php
Normal file
52
resources/views/admin/syndication/edit.blade.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
@extends('master')
|
||||
|
||||
@section('title')Edit Syndication Target « Admin CP « @stop
|
||||
|
||||
@section('content')
|
||||
<h1>Edit syndication target</h1>
|
||||
<form action="/admin/syndication/{{ $syndication_target->id }}" method="post" accept-charset="utf-8" class="admin-form form">
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('PUT') }}
|
||||
<div>
|
||||
<label for="uid">Target UID:</label>
|
||||
<input type="text" name="uid" id="uid" value="{{ old('target_uid', $syndication_target->uid) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Target Name:</label>
|
||||
<input type="text" name="name" id="name" value="{{ old('target_name', $syndication_target->name) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_name">Service Name:</label>
|
||||
<input type="text" name="service_name" id="service_name" value="{{ old('service_name', $syndication_target->service_name) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_url">Service URL:</label>
|
||||
<input type="text" name="service_url" id="service_url" value="{{ old('service_url', $syndication_target->service_url) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="service_photo">Service Logo:</label>
|
||||
<input type="text" name="service_photo" id="service_photo" value="{{ old('service_photo', $syndication_target->service_photo) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_name">User Name:</label>
|
||||
<input type="text" name="user_name" id="user_name" value="{{ old('user_name', $syndication_target->user_name) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_url">User URL:</label>
|
||||
<input type="text" name="user_url" id="user_url" value="{{ old('user_url', $syndication_target->user_url) }}">
|
||||
</div>
|
||||
<div>
|
||||
<label for="user_photo">User Photo:</label>
|
||||
<input type="text" name="user_photo" id="user_photo" value="{{ old('user_photo', $syndication_target->user_photo) }}">
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" name="edit">Edit</button>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<form action="/admin/syndication/{{ $syndication_target->id }}" method="post">
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('DELETE') }}
|
||||
<button type="submit" name="delete">Delete syndication target</button>
|
||||
</form>
|
||||
@stop
|
22
resources/views/admin/syndication/index.blade.php
Normal file
22
resources/views/admin/syndication/index.blade.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
@extends('master')
|
||||
|
||||
@section('title')List Syndication Targets « Admin CP « @stop
|
||||
|
||||
@section('content')
|
||||
<h1>Syndication Targets</h1>
|
||||
@if($targets->isEmpty())
|
||||
<p>No saved syndication targets.</p>
|
||||
@else
|
||||
<ul>
|
||||
@foreach($targets as $target)
|
||||
<li>
|
||||
{{ $target['uid'] }}
|
||||
<a href="/admin/syndication/{{ $target['id'] }}/edit">edit?</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<p>
|
||||
Create a <a href="/admin/syndication/create">new syndication target</a>?
|
||||
</p>
|
||||
@stop
|
|
@ -40,4 +40,10 @@
|
|||
You can either <a href="/admin/places/create">create</a> new places,
|
||||
or <a href="/admin/places/">edit</a> them.
|
||||
</p>
|
||||
|
||||
<h2>Syndication</h2>
|
||||
<p>
|
||||
You can either <a href="/admin/syndication/create">create</a> new syndication targets,
|
||||
or <a href="/admin/syndication">edit</a> them.
|
||||
</p>
|
||||
@stop
|
||||
|
|
|
@ -18,6 +18,7 @@ use App\Http\Controllers\Admin\HomeController;
|
|||
use App\Http\Controllers\Admin\LikesController as AdminLikesController;
|
||||
use App\Http\Controllers\Admin\NotesController as AdminNotesController;
|
||||
use App\Http\Controllers\Admin\PlacesController as AdminPlacesController;
|
||||
use App\Http\Controllers\Admin\SyndicationTargetsController;
|
||||
use App\Http\Controllers\ArticlesController;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\BookmarksController;
|
||||
|
@ -122,6 +123,16 @@ Route::group(['domain' => config('url.longurl')], function () {
|
|||
Route::put('/{id}', [AdminLikesController::class, 'update']);
|
||||
Route::delete('/{id}', [AdminLikesController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// Syndication Targets
|
||||
Route::group(['prefix' => 'syndication'], function () {
|
||||
Route::get('/', [SyndicationTargetsController::class, 'index']);
|
||||
Route::get('/create', [SyndicationTargetsController::class, 'create']);
|
||||
Route::post('/', [SyndicationTargetsController::class, 'store']);
|
||||
Route::get('/{syndicationTarget}/edit', [SyndicationTargetsController::class, 'edit']);
|
||||
Route::put('/{syndicationTarget}', [SyndicationTargetsController::class, 'update']);
|
||||
Route::delete('/{syndicationTarget}', [SyndicationTargetsController::class, 'destroy']);
|
||||
});
|
||||
});
|
||||
|
||||
// Blog pages using ArticlesController
|
||||
|
|
Loading…
Add table
Reference in a new issue