Upgrade to Laravel 10
This commit is contained in:
parent
c4d7dc31d5
commit
16b120bc73
142 changed files with 1676 additions and 2019 deletions
|
@ -5,17 +5,23 @@ root = true
|
||||||
|
|
||||||
# Unix-style newlines with a newline ending every file
|
# Unix-style newlines with a newline ending every file
|
||||||
[*]
|
[*]
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
# Tab indentation
|
# Tab indentation
|
||||||
[Makefile]
|
[Makefile]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
tab_width = 4
|
tab_width = 4
|
||||||
|
|
||||||
[yml]
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
||||||
|
|
|
@ -25,22 +25,10 @@ class MigratePlaceDataFromPostgis extends Command
|
||||||
*/
|
*/
|
||||||
protected $description = 'Copy Postgis data to normal latitude longitude fields';
|
protected $description = 'Copy Postgis data to normal latitude longitude fields';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$locationColumn = DB::selectOne(DB::raw("
|
$locationColumn = DB::selectOne(DB::raw("
|
||||||
SELECT EXISTS (
|
SELECT EXISTS (
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\WebMention;
|
use App\Models\WebMention;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||||
use Illuminate\FileSystem\FileSystem;
|
use Illuminate\FileSystem\FileSystem;
|
||||||
|
|
||||||
class ParseCachedWebMentions extends Command
|
class ParseCachedWebMentions extends Command
|
||||||
|
@ -27,9 +28,9 @@ class ParseCachedWebMentions extends Command
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public function handle(FileSystem $filesystem)
|
public function handle(FileSystem $filesystem): void
|
||||||
{
|
{
|
||||||
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
|
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
|
||||||
foreach ($htmlFiles as $file) {
|
foreach ($htmlFiles as $file) {
|
||||||
|
@ -49,8 +50,6 @@ class ParseCachedWebMentions extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the source URL from a filename.
|
* Determine the source URL from a filename.
|
||||||
*
|
|
||||||
* @param string
|
|
||||||
*/
|
*/
|
||||||
private function urlFromFilename(string $filepath): string
|
private function urlFromFilename(string $filepath): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,22 +24,10 @@ class ReDownloadWebMentions extends Command
|
||||||
*/
|
*/
|
||||||
protected $description = 'Redownload the HTML content of webmentions';
|
protected $description = 'Redownload the HTML content of webmentions';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$webmentions = WebMention::all();
|
$webmentions = WebMention::all();
|
||||||
foreach ($webmentions as $webmention) {
|
foreach ($webmentions as $webmention) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Kernel extends ConsoleKernel
|
||||||
/**
|
/**
|
||||||
* The Artisan commands provided by your application.
|
* The Artisan commands provided by your application.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
Commands\ParseCachedWebMentions::class,
|
Commands\ParseCachedWebMentions::class,
|
||||||
|
@ -20,11 +20,9 @@ class Kernel extends ConsoleKernel
|
||||||
/**
|
/**
|
||||||
* Define the application's command schedule.
|
* Define the application's command schedule.
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule): void
|
||||||
{
|
{
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
$schedule->command('cache:prune-stale-tags')->hourly();
|
$schedule->command('cache:prune-stale-tags')->hourly();
|
||||||
|
@ -32,10 +30,8 @@ class Kernel extends ConsoleKernel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the commands for the application.
|
* Register the commands for the application.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function commands()
|
protected function commands(): void
|
||||||
{
|
{
|
||||||
$this->load(__DIR__ . '/Commands');
|
$this->load(__DIR__ . '/Commands');
|
||||||
|
|
||||||
|
|
|
@ -21,46 +21,34 @@ class Handler extends ExceptionHandler
|
||||||
/**
|
/**
|
||||||
* A list of the exception types that are not reported.
|
* A list of the exception types that are not reported.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, class-string<\Throwable>>
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
NotFoundHttpException::class,
|
NotFoundHttpException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of the inputs that are never flashed for validation exceptions.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dontFlash = [
|
|
||||||
'password',
|
|
||||||
'password_confirmation',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report or log an exception.
|
* Report or log an exception.
|
||||||
*
|
*
|
||||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function report(Throwable $throwable)
|
public function report(Throwable $e): void
|
||||||
{
|
{
|
||||||
parent::report($throwable);
|
parent::report($e);
|
||||||
|
|
||||||
if (config('logging.slack') && $this->shouldReport($throwable)) {
|
if (config('logging.slack') && $this->shouldReport($e)) {
|
||||||
$guzzle = new Client([
|
$guzzle = new Client([
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$exceptionName = get_class($throwable) ?? 'Unknown Exception';
|
$exceptionName = get_class($e) ?? 'Unknown Exception';
|
||||||
$title = $exceptionName . ': ' . $throwable->getMessage();
|
$title = $exceptionName . ': ' . $e->getMessage();
|
||||||
|
|
||||||
$guzzle->post(
|
$guzzle->post(
|
||||||
config('logging.slack'),
|
config('logging.slack'),
|
||||||
|
|
|
@ -27,10 +27,8 @@ class ArticlesController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a single article.
|
* Show a single article.
|
||||||
*
|
|
||||||
* @return RedirectResponse|View
|
|
||||||
*/
|
*/
|
||||||
public function show(int $year, int $month, string $slug)
|
public function show(int $year, int $month, string $slug): RedirectResponse|View
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$article = Article::where('titleurl', $slug)->firstOrFail();
|
$article = Article::where('titleurl', $slug)->firstOrFail();
|
||||||
|
@ -49,8 +47,7 @@ class ArticlesController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We only have the ID, work out post title, year and month
|
* We only have the ID, work out post title, year and month and redirect to it.
|
||||||
* and redirect to it.
|
|
||||||
*/
|
*/
|
||||||
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
|
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
@ -12,10 +13,8 @@ class AuthController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show the login form.
|
* Show the login form.
|
||||||
*
|
|
||||||
* @return View|RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function showLogin()
|
public function showLogin(): View|RedirectResponse
|
||||||
{
|
{
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
|
@ -25,12 +24,11 @@ class AuthController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log in a user, set a session variable, check credentials against
|
* Log in a user, set a session variable, check credentials against the `.env` file.
|
||||||
* the .env file.
|
|
||||||
*/
|
*/
|
||||||
public function login(): RedirectResponse
|
public function login(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$credentials = request()->only('name', 'password');
|
$credentials = $request->only('name', 'password');
|
||||||
|
|
||||||
if (Auth::attempt($credentials, true)) {
|
if (Auth::attempt($credentials, true)) {
|
||||||
return redirect()->intended('/');
|
return redirect()->intended('/');
|
||||||
|
@ -40,11 +38,9 @@ class AuthController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form to logout a user.
|
* Show the form to allow a user to log-out.
|
||||||
*
|
|
||||||
* @return View|RedirectResponse
|
|
||||||
*/
|
*/
|
||||||
public function showLogout()
|
public function showLogout(): View|RedirectResponse
|
||||||
{
|
{
|
||||||
if (Auth::check() === false) {
|
if (Auth::check() === false) {
|
||||||
// The user is not logged in, just redirect them home
|
// The user is not logged in, just redirect them home
|
||||||
|
@ -56,8 +52,6 @@ class AuthController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log the user out from their current session.
|
* Log the user out from their current session.
|
||||||
*
|
|
||||||
* @return RedirectResponse;
|
|
||||||
*/
|
*/
|
||||||
public function logout(): RedirectResponse
|
public function logout(): RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,10 +96,8 @@ class FeedsController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the notes JSON feed.
|
* Returns the notes JSON feed.
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function notesJson()
|
public function notesJson(): array
|
||||||
{
|
{
|
||||||
$notes = Note::latest()->with('media')->take(20)->get();
|
$notes = Note::latest()->with('media')->take(20)->get();
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\Bookmark;
|
||||||
use App\Models\Like;
|
use App\Models\Like;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use App\Services\ActivityStreamsService;
|
use App\Services\ActivityStreamsService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
@ -14,12 +15,10 @@ class FrontPageController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show all the recent activity.
|
* Show all the recent activity.
|
||||||
*
|
|
||||||
* @return Response|View
|
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(Request $request): Response|View
|
||||||
{
|
{
|
||||||
if (request()->wantsActivityStream()) {
|
if ($request->wantsActivityStream()) {
|
||||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,34 +115,34 @@ class MicropubController extends Controller
|
||||||
* appropriately. Further if the request has the query parameter
|
* appropriately. Further if the request has the query parameter
|
||||||
* syndicate-to we respond with the known syndication endpoints.
|
* syndicate-to we respond with the known syndication endpoints.
|
||||||
*/
|
*/
|
||||||
public function get(): JsonResponse
|
public function get(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
||||||
return (new MicropubResponses())->invalidTokenResponse();
|
return (new MicropubResponses())->invalidTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->input('q') === 'syndicate-to') {
|
if ($request->input('q') === 'syndicate-to') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'syndicate-to' => SyndicationTarget::all(),
|
'syndicate-to' => SyndicationTarget::all(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->input('q') === 'config') {
|
if ($request->input('q') === 'config') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'syndicate-to' => SyndicationTarget::all(),
|
'syndicate-to' => SyndicationTarget::all(),
|
||||||
'media-endpoint' => route('media-endpoint'),
|
'media-endpoint' => route('media-endpoint'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->has('q') && substr(request()->input('q'), 0, 4) === 'geo:') {
|
if ($request->has('q') && str_starts_with($request->input('q'), 'geo:')) {
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/([0-9.\-]+)/',
|
'/([0-9.\-]+)/',
|
||||||
request()->input('q'),
|
$request->input('q'),
|
||||||
$matches
|
$matches
|
||||||
);
|
);
|
||||||
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
|
$distance = (count($matches[0]) === 3) ? 100 * $matches[0][2] : 1000;
|
||||||
$places = Place::near(
|
$places = Place::near(
|
||||||
(object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]],
|
(object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]],
|
||||||
$distance
|
$distance
|
||||||
|
@ -168,22 +168,19 @@ class MicropubController extends Controller
|
||||||
/**
|
/**
|
||||||
* Determine the client id from the access token sent with the request.
|
* Determine the client id from the access token sent with the request.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws RequiredConstraintsViolated
|
* @throws RequiredConstraintsViolated
|
||||||
*/
|
*/
|
||||||
private function getClientId(): string
|
private function getClientId(): string
|
||||||
{
|
{
|
||||||
return resolve(TokenService::class)
|
return resolve(TokenService::class)
|
||||||
->validateToken(request()->input('access_token'))
|
->validateToken(app('request')->input('access_token'))
|
||||||
->claims()->get('client_id');
|
->claims()->get('client_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the details of the micropub request to a log file.
|
* Save the details of the micropub request to a log file.
|
||||||
*
|
|
||||||
* @param array $request This is the info from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function logMicropubRequest(array $request)
|
private function logMicropubRequest(array $request): void
|
||||||
{
|
{
|
||||||
$logger = new Logger('micropub');
|
$logger = new Logger('micropub');
|
||||||
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));
|
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));
|
||||||
|
|
|
@ -98,14 +98,13 @@ class MicropubMediaController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a media item posted to the media endpoint.
|
* Process a media item posted to the media endpoint.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws BindingResolutionException
|
* @throws BindingResolutionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function media(): JsonResponse
|
public function media(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) {
|
} catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) {
|
||||||
$micropubResponses = new MicropubResponses();
|
$micropubResponses = new MicropubResponses();
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ class MicropubMediaController extends Controller
|
||||||
return $micropubResponses->insufficientScopeResponse();
|
return $micropubResponses->insufficientScopeResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->hasFile('file') === false) {
|
if ($request->hasFile('file') === false) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'response' => 'error',
|
'response' => 'error',
|
||||||
'error' => 'invalid_request',
|
'error' => 'invalid_request',
|
||||||
|
@ -132,7 +131,7 @@ class MicropubMediaController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request()->file('file')->isValid() === false) {
|
if ($request->file('file')->isValid() === false) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'response' => 'error',
|
'response' => 'error',
|
||||||
'error' => 'invalid_request',
|
'error' => 'invalid_request',
|
||||||
|
@ -140,11 +139,11 @@ class MicropubMediaController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = $this->saveFile(request()->file('file'));
|
$filename = $this->saveFile($request->file('file'));
|
||||||
|
|
||||||
$manager = resolve(ImageManager::class);
|
$manager = resolve(ImageManager::class);
|
||||||
try {
|
try {
|
||||||
$image = $manager->make(request()->file('file'));
|
$image = $manager->make($request->file('file'));
|
||||||
$width = $image->width();
|
$width = $image->width();
|
||||||
} catch (NotReadableException $exception) {
|
} catch (NotReadableException $exception) {
|
||||||
// not an image
|
// not an image
|
||||||
|
@ -152,9 +151,9 @@ class MicropubMediaController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$media = Media::create([
|
$media = Media::create([
|
||||||
'token' => request()->bearerToken(),
|
'token' => $request->bearerToken(),
|
||||||
'path' => 'media/' . $filename,
|
'path' => 'media/' . $filename,
|
||||||
'type' => $this->getFileTypeFromMimeType(request()->file('file')->getMimeType()),
|
'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
|
||||||
'image_widths' => $width,
|
'image_widths' => $width,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -226,7 +225,6 @@ class MicropubMediaController extends Controller
|
||||||
/**
|
/**
|
||||||
* Save an uploaded file to the local disk.
|
* Save an uploaded file to the local disk.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function saveFile(UploadedFile $file): string
|
private function saveFile(UploadedFile $file): string
|
||||||
|
|
|
@ -9,6 +9,7 @@ use App\Services\ActivityStreamsService;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
@ -19,12 +20,10 @@ class NotesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show all the notes. This is also the homepage.
|
* Show all the notes. This is also the homepage.
|
||||||
*
|
|
||||||
* @return View|Response
|
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(Request $request): View|Response
|
||||||
{
|
{
|
||||||
if (request()->wantsActivityStream()) {
|
if ($request->wantsActivityStream()) {
|
||||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +38,8 @@ class NotesController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a single note.
|
* Show a single note.
|
||||||
*
|
|
||||||
* @param string $urlId The id of the note
|
|
||||||
* @return View|JsonResponse|Response
|
|
||||||
*/
|
*/
|
||||||
public function show(string $urlId)
|
public function show(string $urlId): View|JsonResponse|Response
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
||||||
|
@ -60,8 +56,6 @@ class NotesController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect /note/{decID} to /notes/{nb60id}.
|
* Redirect /note/{decID} to /notes/{nb60id}.
|
||||||
*
|
|
||||||
* @param int $decId The decimal id of the note
|
|
||||||
*/
|
*/
|
||||||
public function redirect(int $decId): RedirectResponse
|
public function redirect(int $decId): RedirectResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,17 +35,15 @@ class ShortURLsController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect a short url of this site out to a long one based on post type.
|
* Redirect a short url of this site out to a long one based on post type.
|
||||||
* Further redirects may happen.
|
|
||||||
*
|
*
|
||||||
* @param string Post type
|
* Further redirects may happen.
|
||||||
* @param string Post ID
|
|
||||||
*/
|
*/
|
||||||
public function expandType(string $type, string $postId): RedirectResponse
|
public function expandType(string $type, string $postId): RedirectResponse
|
||||||
{
|
{
|
||||||
if ($type == 't') {
|
if ($type === 't') {
|
||||||
$type = 'notes';
|
$type = 'notes';
|
||||||
}
|
}
|
||||||
if ($type == 'b') {
|
if ($type === 'b') {
|
||||||
$type = 'blog/s';
|
$type = 'blog/s';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,6 @@ class TokenEndpointController extends Controller
|
||||||
*/
|
*/
|
||||||
protected GuzzleClient $guzzle;
|
protected GuzzleClient $guzzle;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TokenService The Token handling service.
|
|
||||||
*/
|
|
||||||
protected TokenService $tokenService;
|
protected TokenService $tokenService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Http\Controllers;
|
||||||
use App\Jobs\ProcessWebMention;
|
use App\Jobs\ProcessWebMention;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
@ -27,10 +28,10 @@ class WebMentionsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Receive and process a webmention.
|
* Receive and process a webmention.
|
||||||
*/
|
*/
|
||||||
public function receive(): Response
|
public function receive(Request $request): Response
|
||||||
{
|
{
|
||||||
//first we trivially reject requests that lack all required inputs
|
//first we trivially reject requests that lack all required inputs
|
||||||
if ((request()->has('target') !== true) || (request()->has('source') !== true)) {
|
if (($request->has('target') !== true) || ($request->has('source') !== true)) {
|
||||||
return response(
|
return response(
|
||||||
'You need both the target and source parameters',
|
'You need both the target and source parameters',
|
||||||
400
|
400
|
||||||
|
@ -38,15 +39,15 @@ class WebMentionsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//next check the $target is valid
|
//next check the $target is valid
|
||||||
$path = parse_url(request()->input('target'), PHP_URL_PATH);
|
$path = parse_url($request->input('target'), PHP_URL_PATH);
|
||||||
$pathParts = explode('/', $path);
|
$pathParts = explode('/', $path);
|
||||||
|
|
||||||
if ($pathParts[1] == 'notes') {
|
if ($pathParts[1] === 'notes') {
|
||||||
//we have a note
|
//we have a note
|
||||||
$noteId = $pathParts[2];
|
$noteId = $pathParts[2];
|
||||||
try {
|
try {
|
||||||
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
|
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
|
||||||
dispatch(new ProcessWebMention($note, request()->input('source')));
|
dispatch(new ProcessWebMention($note, $request->input('source')));
|
||||||
} catch (ModelNotFoundException $e) {
|
} catch (ModelNotFoundException $e) {
|
||||||
return response('This note doesn’t exist.', 400);
|
return response('This note doesn’t exist.', 400);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ class WebMentionsController extends Controller
|
||||||
202
|
202
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($pathParts[1] == 'blog') {
|
if ($pathParts[1] === 'blog') {
|
||||||
return response(
|
return response(
|
||||||
'I don’t accept webmentions for blog posts yet.',
|
'I don’t accept webmentions for blog posts yet.',
|
||||||
501
|
501
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Kernel extends HttpKernel
|
||||||
*
|
*
|
||||||
* These middleware are run during every request to your application.
|
* These middleware are run during every request to your application.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, class-string|string>
|
||||||
*/
|
*/
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
// \App\Http\Middleware\TrustHosts::class,
|
// \App\Http\Middleware\TrustHosts::class,
|
||||||
|
@ -26,7 +26,7 @@ class Kernel extends HttpKernel
|
||||||
/**
|
/**
|
||||||
* The application's route middleware groups.
|
* The application's route middleware groups.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string, array<int, class-string|string>>
|
||||||
*/
|
*/
|
||||||
protected $middlewareGroups = [
|
protected $middlewareGroups = [
|
||||||
'web' => [
|
'web' => [
|
||||||
|
@ -44,21 +44,23 @@ class Kernel extends HttpKernel
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'throttle:api',
|
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
|
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application's route middleware.
|
* The application's middleware aliases.
|
||||||
*
|
*
|
||||||
* These middleware may be assigned to groups or used individually.
|
* Aliases may be used to conveniently assign middleware to routes and groups.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string, class-string|string>
|
||||||
*/
|
*/
|
||||||
protected $middlewareAliases = [
|
protected $middlewareAliases = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
|
|
@ -6,15 +6,14 @@ namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class ActivityStreamLinks
|
class ActivityStreamLinks
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
$response = $next($request);
|
$response = $next($request);
|
||||||
if ($request->path() === '/') {
|
if ($request->path() === '/') {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
|
@ -11,14 +12,9 @@ class Authenticate extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the path the user should be redirected to when they are not authenticated.
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function redirectTo($request)
|
protected function redirectTo(Request $request): ?string
|
||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
return $request->expectsJson() ? null : route('login');
|
||||||
return route('login');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,14 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class CSPHeader
|
class CSPHeader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (App::environment('local', 'development')) {
|
if (App::environment('local', 'development')) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
|
||||||
|
|
||||||
class CheckForMaintenanceMode extends Middleware
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The URIs that should be reachable while maintenance mode is enabled.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $except = [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -3,16 +3,15 @@
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class CorsHeaders
|
class CorsHeaders
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle(Request$request, Closure $next): Response
|
||||||
{
|
{
|
||||||
$response = $next($request);
|
$response = $next($request);
|
||||||
if ($request->path() === 'api/media') {
|
if ($request->path() === 'api/media') {
|
||||||
|
|
|
@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
|
||||||
/**
|
/**
|
||||||
* The names of the cookies that should not be encrypted.
|
* The names of the cookies that should not be encrypted.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
//
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class LinkHeadersMiddleware
|
class LinkHeadersMiddleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
$response = $next($request);
|
$response = $next($request);
|
||||||
$response->header('Link', '<https://indieauth.com/auth>; rel="authorization_endpoint"', false);
|
$response->header('Link', '<https://indieauth.com/auth>; rel="authorization_endpoint"', false);
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class LocalhostSessionMiddleware
|
class LocalhostSessionMiddleware
|
||||||
{
|
{
|
||||||
|
@ -13,10 +14,8 @@ class LocalhostSessionMiddleware
|
||||||
* Whilst we are developing locally, automatically log in as
|
* Whilst we are developing locally, automatically log in as
|
||||||
* `['me' => config('app.url')]` as I can’t manually log in as
|
* `['me' => config('app.url')]` as I can’t manually log in as
|
||||||
* a .localhost domain.
|
* a .localhost domain.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (config('app.env') !== 'production') {
|
if (config('app.env') !== 'production') {
|
||||||
session(['me' => config('app.url')]);
|
session(['me' => config('app.url')]);
|
||||||
|
|
|
@ -7,18 +7,17 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class MyAuthMiddleware
|
class MyAuthMiddleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Check the user is logged in.
|
* Check the user is logged in.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if (Auth::check($request->user()) == false) {
|
if (Auth::check() === false) {
|
||||||
//they’re not logged in, so send them to login form
|
// they’re not logged in, so send them to login form
|
||||||
return redirect()->route('login');
|
return redirect()->route('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class PreventRequestsDuringMaintenance extends Middleware
|
||||||
/**
|
/**
|
||||||
* The URIs that should be reachable while maintenance mode is enabled.
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
//
|
//
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Providers\RouteServiceProvider;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
|
@ -15,10 +16,9 @@ class RedirectIfAuthenticated
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
* @param string|null ...$guards
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next, ...$guards)
|
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||||
{
|
{
|
||||||
$guards = empty($guards) ? [null] : $guards;
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@ class TrimStrings extends Middleware
|
||||||
/**
|
/**
|
||||||
* The names of the attributes that should not be trimmed.
|
* The names of the attributes that should not be trimmed.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
|
'current_password',
|
||||||
'password',
|
'password',
|
||||||
'password_confirmation',
|
'password_confirmation',
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,9 +12,9 @@ class TrustHosts extends Middleware
|
||||||
/**
|
/**
|
||||||
* Get the host patterns that should be trusted.
|
* Get the host patterns that should be trusted.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<int, string|null>
|
||||||
*/
|
*/
|
||||||
public function hosts()
|
public function hosts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
$this->allSubdomainsOfApplicationUrl(),
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
|
|
@ -10,7 +10,7 @@ class TrustProxies extends Middleware
|
||||||
/**
|
/**
|
||||||
* The trusted proxies for this application.
|
* The trusted proxies for this application.
|
||||||
*
|
*
|
||||||
* @var array|string
|
* @var array<int, string>|string|null
|
||||||
*/
|
*/
|
||||||
protected $proxies;
|
protected $proxies;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
|
||||||
/**
|
/**
|
||||||
* The URIs that should be excluded from CSRF verification.
|
* The URIs that should be excluded from CSRF verification.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
'api/media',
|
'api/media',
|
||||||
|
|
|
@ -6,15 +6,14 @@ namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class VerifyMicropubToken
|
class VerifyMicropubToken
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
if ($request->input('access_token')) {
|
if ($request->input('access_token')) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|
|
@ -18,24 +18,22 @@ class AddClientToDatabase implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
protected $client_id;
|
protected string $client_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(string $client_id)
|
public function __construct(string $clientId)
|
||||||
{
|
{
|
||||||
$this->client_id = $client_id;
|
$this->client_id = $clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): void
|
||||||
{
|
{
|
||||||
if (MicropubClient::where('client_url', $this->client_id)->count() == 0) {
|
if (MicropubClient::where('client_url', $this->client_id)->count() === 0) {
|
||||||
MicropubClient::create([
|
MicropubClient::create([
|
||||||
'client_url' => $this->client_id,
|
'client_url' => $this->client_id,
|
||||||
'client_name' => $this->client_id, // default client name is the URL
|
'client_name' => $this->client_id, // default client name is the URL
|
||||||
|
|
|
@ -19,34 +19,26 @@ class DownloadWebMention implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
|
||||||
* The webmention source URL.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $source;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(string $source)
|
public function __construct(
|
||||||
{
|
protected string $source
|
||||||
$this->source = $source;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public function handle(Client $guzzle)
|
public function handle(Client $guzzle): void
|
||||||
{
|
{
|
||||||
$response = $guzzle->request('GET', $this->source);
|
$response = $guzzle->request('GET', $this->source);
|
||||||
//4XX and 5XX responses should get Guzzle to throw an exception,
|
//4XX and 5XX responses should get Guzzle to throw an exception,
|
||||||
//Laravel should catch and retry these automatically.
|
//Laravel should catch and retry these automatically.
|
||||||
if ($response->getStatusCode() == '200') {
|
if ($response->getStatusCode() === 200) {
|
||||||
$filesystem = new FileSystem();
|
$filesystem = new FileSystem();
|
||||||
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
||||||
//backup file first
|
//backup file first
|
||||||
|
@ -69,7 +61,7 @@ class DownloadWebMention implements ShouldQueue
|
||||||
);
|
);
|
||||||
//remove backup if the same
|
//remove backup if the same
|
||||||
if ($filesystem->exists($filenameBackup)) {
|
if ($filesystem->exists($filenameBackup)) {
|
||||||
if ($filesystem->get($filename) == $filesystem->get($filenameBackup)) {
|
if ($filesystem->get($filename) === $filesystem->get($filenameBackup)) {
|
||||||
$filesystem->delete($filenameBackup);
|
$filesystem->delete($filenameBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,13 +70,11 @@ class DownloadWebMention implements ShouldQueue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file path from a URL. This is used when caching the HTML response.
|
* Create a file path from a URL. This is used when caching the HTML response.
|
||||||
*
|
|
||||||
* @return string The path name
|
|
||||||
*/
|
*/
|
||||||
private function createFilenameFromURL(string $url)
|
private function createFilenameFromURL(string $url): string
|
||||||
{
|
{
|
||||||
$filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url);
|
$filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url);
|
||||||
if (substr($filepath, -1) == '/') {
|
if (str_ends_with($filepath, '/')) {
|
||||||
$filepath .= 'index.html';
|
$filepath .= 'index.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,12 @@ class ProcessBookmark implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
protected Bookmark $bookmark;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Bookmark $bookmark)
|
public function __construct(
|
||||||
{
|
protected Bookmark $bookmark
|
||||||
$this->bookmark = $bookmark;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,21 +25,17 @@ class ProcessLike implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var Like */
|
|
||||||
protected $like;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Like $like)
|
public function __construct(
|
||||||
{
|
protected Like $like
|
||||||
$this->like = $like;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function handle(Client $client, Authorship $authorship): int
|
public function handle(Client $client, Authorship $authorship): int
|
||||||
|
|
|
@ -20,21 +20,18 @@ class ProcessMedia implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $filename;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(string $filename)
|
public function __construct(
|
||||||
{
|
protected string $filename
|
||||||
$this->filename = $filename;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*/
|
*/
|
||||||
public function handle(ImageManager $manager)
|
public function handle(ImageManager $manager): void
|
||||||
{
|
{
|
||||||
//open file
|
//open file
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -24,30 +24,23 @@ class ProcessWebMention implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var Note */
|
|
||||||
protected $note;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $source;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Note $note, string $source)
|
public function __construct(
|
||||||
{
|
protected Note $note,
|
||||||
$this->note = $note;
|
protected string $source
|
||||||
$this->source = $source;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws RemoteContentNotFoundException
|
* @throws RemoteContentNotFoundException
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
* @throws InvalidMentionException
|
* @throws InvalidMentionException
|
||||||
*/
|
*/
|
||||||
public function handle(Parser $parser, Client $guzzle)
|
public function handle(Parser $parser, Client $guzzle): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = $guzzle->request('GET', $this->source);
|
$response = $guzzle->request('GET', $this->source);
|
||||||
|
@ -60,8 +53,8 @@ class ProcessWebMention implements ShouldQueue
|
||||||
foreach ($webmentions as $webmention) {
|
foreach ($webmentions as $webmention) {
|
||||||
// check webmention still references target
|
// check webmention still references target
|
||||||
// we try each type of mention (reply/like/repost)
|
// we try each type of mention (reply/like/repost)
|
||||||
if ($webmention->type == 'in-reply-to') {
|
if ($webmention->type === 'in-reply-to') {
|
||||||
if ($parser->checkInReplyTo($microformats, $this->note->longurl) == false) {
|
if ($parser->checkInReplyTo($microformats, $this->note->longurl) === false) {
|
||||||
// it doesn’t so delete
|
// it doesn’t so delete
|
||||||
$webmention->delete();
|
$webmention->delete();
|
||||||
|
|
||||||
|
@ -74,16 +67,16 @@ class ProcessWebMention implements ShouldQueue
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($webmention->type == 'like-of') {
|
if ($webmention->type === 'like-of') {
|
||||||
if ($parser->checkLikeOf($microformats, $this->note->longurl) == false) {
|
if ($parser->checkLikeOf($microformats, $this->note->longurl) === false) {
|
||||||
// it doesn’t so delete
|
// it doesn’t so delete
|
||||||
$webmention->delete();
|
$webmention->delete();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} // note we don’t need to do anything if it still is a like
|
} // note we don’t need to do anything if it still is a like
|
||||||
}
|
}
|
||||||
if ($webmention->type == 'repost-of') {
|
if ($webmention->type === 'repost-of') {
|
||||||
if ($parser->checkRepostOf($microformats, $this->note->longurl) == false) {
|
if ($parser->checkRepostOf($microformats, $this->note->longurl) === false) {
|
||||||
// it doesn’t so delete
|
// it doesn’t so delete
|
||||||
$webmention->delete();
|
$webmention->delete();
|
||||||
|
|
||||||
|
@ -107,26 +100,23 @@ class ProcessWebMention implements ShouldQueue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the HTML of a webmention for future use.
|
* Save the HTML of a webmention for future use.
|
||||||
*
|
|
||||||
* @param string $html
|
|
||||||
* @param string $url
|
|
||||||
*/
|
*/
|
||||||
private function saveRemoteContent($html, $url)
|
private function saveRemoteContent(string $html, string $url): void
|
||||||
{
|
{
|
||||||
$filenameFromURL = str_replace(
|
$filenameFromURL = str_replace(
|
||||||
['https://', 'http://'],
|
['https://', 'http://'],
|
||||||
['https/', 'http/'],
|
['https/', 'http/'],
|
||||||
$url
|
$url
|
||||||
);
|
);
|
||||||
if (substr($url, -1) == '/') {
|
if (str_ends_with($url, '/')) {
|
||||||
$filenameFromURL .= 'index.html';
|
$filenameFromURL .= 'index.html';
|
||||||
}
|
}
|
||||||
$path = storage_path() . '/HTML/' . $filenameFromURL;
|
$path = storage_path() . '/HTML/' . $filenameFromURL;
|
||||||
$parts = explode('/', $path);
|
$parts = explode('/', $path);
|
||||||
$name = array_pop($parts);
|
$name = array_pop($parts);
|
||||||
$dir = implode('/', $parts);
|
$dir = implode('/', $parts);
|
||||||
if (! is_dir($dir)) {
|
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||||
mkdir($dir, 0755, true);
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||||
}
|
}
|
||||||
file_put_contents("$dir/$name", $html);
|
file_put_contents("$dir/$name", $html);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,25 +20,23 @@ class SaveProfileImage implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
protected array $microformats;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $microformats)
|
public function __construct(
|
||||||
{
|
protected array $microformats
|
||||||
$this->microformats = $microformats;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*/
|
*/
|
||||||
public function handle(Authorship $authorship)
|
public function handle(Authorship $authorship): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$author = $authorship->findAuthor($this->microformats);
|
$author = $authorship->findAuthor($this->microformats);
|
||||||
} catch (AuthorshipParserException) {
|
} catch (AuthorshipParserException) {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo = Arr::get($author, 'properties.photo.0');
|
$photo = Arr::get($author, 'properties.photo.0');
|
||||||
|
@ -47,8 +45,8 @@ class SaveProfileImage implements ShouldQueue
|
||||||
//dont save pbs.twimg.com links
|
//dont save pbs.twimg.com links
|
||||||
if (
|
if (
|
||||||
$photo
|
$photo
|
||||||
&& parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
|
&& parse_url($photo, PHP_URL_HOST) !== 'pbs.twimg.com'
|
||||||
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
|
&& parse_url($photo, PHP_URL_HOST) !== 'twitter.com'
|
||||||
) {
|
) {
|
||||||
$client = resolve(Client::class);
|
$client = resolve(Client::class);
|
||||||
|
|
||||||
|
@ -67,8 +65,8 @@ class SaveProfileImage implements ShouldQueue
|
||||||
$parts = explode('/', $path);
|
$parts = explode('/', $path);
|
||||||
$name = array_pop($parts);
|
$name = array_pop($parts);
|
||||||
$dir = implode('/', $parts);
|
$dir = implode('/', $parts);
|
||||||
if (! is_dir($dir)) {
|
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||||
mkdir($dir, 0755, true);
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||||
}
|
}
|
||||||
file_put_contents("$dir/$name", $image);
|
file_put_contents("$dir/$name", $image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,12 @@ class SaveScreenshot implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
private Bookmark $bookmark;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Bookmark $bookmark)
|
public function __construct(
|
||||||
{
|
protected Bookmark $bookmark
|
||||||
$this->bookmark = $bookmark;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,20 +22,17 @@ class SendWebMentions implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
protected Note $note;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the job instance, inject dependencies.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Note $note)
|
public function __construct(
|
||||||
{
|
protected Note $note
|
||||||
$this->note = $note;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
|
@ -60,7 +57,6 @@ class SendWebMentions implements ShouldQueue
|
||||||
/**
|
/**
|
||||||
* Discover if a URL has a webmention endpoint.
|
* Discover if a URL has a webmention endpoint.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function discoverWebmentionEndpoint(string $url): ?string
|
public function discoverWebmentionEndpoint(string $url): ?string
|
||||||
|
@ -126,8 +122,6 @@ class SendWebMentions implements ShouldQueue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a URI if necessary.
|
* Resolve a URI if necessary.
|
||||||
*
|
|
||||||
* @param string $base The base of the URL
|
|
||||||
*/
|
*/
|
||||||
public function resolveUri(string $url, string $base): string
|
public function resolveUri(string $url, string $base): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,24 +20,20 @@ class SyndicateBookmarkToTwitter implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var Bookmark */
|
|
||||||
protected $bookmark;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Bookmark $bookmark)
|
public function __construct(
|
||||||
{
|
protected Bookmark $bookmark
|
||||||
$this->bookmark = $bookmark;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function handle(Client $guzzle)
|
public function handle(Client $guzzle): void
|
||||||
{
|
{
|
||||||
//send webmention
|
//send webmention
|
||||||
$response = $guzzle->request(
|
$response = $guzzle->request(
|
||||||
|
@ -52,7 +48,7 @@ class SyndicateBookmarkToTwitter implements ShouldQueue
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//parse for syndication URL
|
//parse for syndication URL
|
||||||
if ($response->getStatusCode() == 201) {
|
if ($response->getStatusCode() === 201) {
|
||||||
$json = json_decode((string) $response->getBody());
|
$json = json_decode((string) $response->getBody());
|
||||||
$syndicates = $this->bookmark->syndicates;
|
$syndicates = $this->bookmark->syndicates;
|
||||||
$syndicates['twitter'] = $json->url;
|
$syndicates['twitter'] = $json->url;
|
||||||
|
|
|
@ -19,8 +19,6 @@ class SyndicateNoteToMastodon implements ShouldQueue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected Note $note
|
protected Note $note
|
||||||
|
@ -30,7 +28,6 @@ class SyndicateNoteToMastodon implements ShouldQueue
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function handle(Client $guzzle): void
|
public function handle(Client $guzzle): void
|
||||||
|
|
|
@ -18,15 +18,12 @@ class SyndicateNoteToTwitter implements ShouldQueue
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/** @var Note */
|
|
||||||
protected $note;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Note $note)
|
public function __construct(
|
||||||
{
|
protected Note $note
|
||||||
$this->note = $note;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,20 +24,24 @@ class Article extends Model
|
||||||
use Sluggable;
|
use Sluggable;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The attributes that should be mutated to dates.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The database table used by the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'articles';
|
protected $table = 'articles';
|
||||||
|
|
||||||
|
/** @var array<int, string> */
|
||||||
|
protected $fillable = [
|
||||||
|
'url',
|
||||||
|
'title',
|
||||||
|
'main',
|
||||||
|
'published',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
protected $casts = [
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
'deleted_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the sluggable configuration array for this model.
|
* Return the sluggable configuration array for this model.
|
||||||
*/
|
*/
|
||||||
|
@ -50,18 +54,6 @@ class Article extends Model
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array<int, string>
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'url',
|
|
||||||
'title',
|
|
||||||
'main',
|
|
||||||
'published',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected function html(): Attribute
|
protected function html(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::get(
|
return Attribute::get(
|
||||||
|
|
|
@ -13,28 +13,15 @@ class Bookmark extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = ['url', 'name', 'content'];
|
protected $fillable = ['url', 'name', 'content'];
|
||||||
|
|
||||||
/**
|
/** @var array<string, string> */
|
||||||
* The attributes that should be cast to native types.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'syndicates' => 'array',
|
'syndicates' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
public function tags(): BelongsToMany
|
||||||
* The tags that belong to the bookmark.
|
|
||||||
*
|
|
||||||
* @return BelongsToMany
|
|
||||||
*/
|
|
||||||
public function tags()
|
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('App\Models\Tag');
|
return $this->belongsToMany('App\Models\Tag');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,10 @@ class Contact extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The database table used by the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'contacts';
|
protected $table = 'contacts';
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* We shall guard against mass-migration.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
|
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
|
||||||
|
|
||||||
protected function photo(): Attribute
|
protected function photo(): Attribute
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Like extends Model
|
||||||
use FilterHtml;
|
use FilterHtml;
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
/** @var array<int, string> */
|
||||||
protected $fillable = ['url'];
|
protected $fillable = ['url'];
|
||||||
|
|
||||||
protected function url(): Attribute
|
protected function url(): Attribute
|
||||||
|
|
|
@ -14,23 +14,12 @@ class Media extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'media_endpoint';
|
protected $table = 'media_endpoint';
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = ['token', 'path', 'type', 'image_widths'];
|
protected $fillable = ['token', 'path', 'type', 'image_widths'];
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the note that owns this media.
|
|
||||||
*/
|
|
||||||
public function note(): BelongsTo
|
public function note(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Note::class);
|
return $this->belongsTo(Note::class);
|
||||||
|
|
|
@ -12,23 +12,12 @@ class MicropubClient extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The table associated with the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'clients';
|
protected $table = 'clients';
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = ['client_url', 'client_name'];
|
protected $fillable = ['client_url', 'client_name'];
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with notes.
|
|
||||||
*/
|
|
||||||
public function notes(): HasMany
|
public function notes(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Note', 'client_id', 'client_url');
|
return $this->hasMany('App\Models\Note', 'client_id', 'client_url');
|
||||||
|
|
|
@ -58,73 +58,46 @@ class Note extends Model
|
||||||
$this->contacts = null;
|
$this->contacts = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The database table used by the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'notes';
|
protected $table = 'notes';
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* Mass-assignment.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'note',
|
'note',
|
||||||
'in_reply_to',
|
'in_reply_to',
|
||||||
'client_id',
|
'client_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* Hide the column used with Laravel Scout.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $hidden = ['searchable'];
|
protected $hidden = ['searchable'];
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with tags.
|
|
||||||
*/
|
|
||||||
public function tags(): BelongsToMany
|
public function tags(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Tag::class);
|
return $this->belongsToMany(Tag::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with clients.
|
|
||||||
*/
|
|
||||||
public function client(): BelongsTo
|
public function client(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(MicropubClient::class, 'client_id', 'client_url');
|
return $this->belongsTo(MicropubClient::class, 'client_id', 'client_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with webmentions.
|
|
||||||
*/
|
|
||||||
public function webmentions(): MorphMany
|
public function webmentions(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphMany(WebMention::class, 'commentable');
|
return $this->morphMany(WebMention::class, 'commentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with places.
|
|
||||||
*/
|
|
||||||
public function place(): BelongsTo
|
public function place(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Place::class);
|
return $this->belongsTo(Place::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the relationship with media.
|
|
||||||
*/
|
|
||||||
public function media(): HasMany
|
public function media(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Media::class);
|
return $this->hasMany(Media::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the attributes to be indexed for searching with Scout.
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
public function toSearchableArray(): array
|
public function toSearchableArray(): array
|
||||||
{
|
{
|
||||||
|
@ -133,9 +106,6 @@ class Note extends Model
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize the note to Unicode FORM C.
|
|
||||||
*/
|
|
||||||
public function setNoteAttribute(?string $value): void
|
public function setNoteAttribute(?string $value): void
|
||||||
{
|
{
|
||||||
if ($value !== null) {
|
if ($value !== null) {
|
||||||
|
@ -195,58 +165,37 @@ class Note extends Model
|
||||||
return $note;
|
return $note;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the NewBase60 ID from primary ID.
|
|
||||||
*/
|
|
||||||
public function getNb60idAttribute(): string
|
public function getNb60idAttribute(): string
|
||||||
{
|
{
|
||||||
// we cast to string because sometimes the nb60id is an “int”
|
// we cast to string because sometimes the nb60id is an “int”
|
||||||
return (string) resolve(Numbers::class)->numto60($this->id);
|
return (string) resolve(Numbers::class)->numto60($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The Long URL for a note.
|
|
||||||
*/
|
|
||||||
public function getLongurlAttribute(): string
|
public function getLongurlAttribute(): string
|
||||||
{
|
{
|
||||||
return config('app.url') . '/notes/' . $this->nb60id;
|
return config('app.url') . '/notes/' . $this->nb60id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The Short URL for a note.
|
|
||||||
*/
|
|
||||||
public function getShorturlAttribute(): string
|
public function getShorturlAttribute(): string
|
||||||
{
|
{
|
||||||
return config('app.shorturl') . '/notes/' . $this->nb60id;
|
return config('app.shorturl') . '/notes/' . $this->nb60id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ISO8601 value for mf2.
|
|
||||||
*/
|
|
||||||
public function getIso8601Attribute(): string
|
public function getIso8601Attribute(): string
|
||||||
{
|
{
|
||||||
return $this->updated_at->toISO8601String();
|
return $this->updated_at->toISO8601String();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ISO8601 value for mf2.
|
|
||||||
*/
|
|
||||||
public function getHumandiffAttribute(): string
|
public function getHumandiffAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->updated_at->diffForHumans();
|
return $this->updated_at->diffForHumans();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the publish date value for RSS feeds.
|
|
||||||
*/
|
|
||||||
public function getPubdateAttribute(): string
|
public function getPubdateAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->updated_at->toRSSString();
|
return $this->updated_at->toRSSString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the latitude value.
|
|
||||||
*/
|
|
||||||
public function getLatitudeAttribute(): ?float
|
public function getLatitudeAttribute(): ?float
|
||||||
{
|
{
|
||||||
if ($this->place !== null) {
|
if ($this->place !== null) {
|
||||||
|
@ -262,9 +211,6 @@ class Note extends Model
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the longitude value.
|
|
||||||
*/
|
|
||||||
public function getLongitudeAttribute(): ?float
|
public function getLongitudeAttribute(): ?float
|
||||||
{
|
{
|
||||||
if ($this->place !== null) {
|
if ($this->place !== null) {
|
||||||
|
@ -281,8 +227,9 @@ class Note extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the address for a note. This is either a reverse geo-code from the
|
* Get the address for a note.
|
||||||
* location, or is derived from the associated place.
|
*
|
||||||
|
* This is either a reverse geo-code from the location, or is derived from the associated place.
|
||||||
*/
|
*/
|
||||||
public function getAddressAttribute(): ?string
|
public function getAddressAttribute(): ?string
|
||||||
{
|
{
|
||||||
|
@ -337,9 +284,6 @@ class Note extends Model
|
||||||
* Show a specific form of the note for twitter.
|
* Show a specific form of the note for twitter.
|
||||||
*
|
*
|
||||||
* That is we swap the contacts names for their known Twitter handles.
|
* That is we swap the contacts names for their known Twitter handles.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @throws TwitterContentException
|
|
||||||
*/
|
*/
|
||||||
public function getTwitterContentAttribute(): string
|
public function getTwitterContentAttribute(): string
|
||||||
{
|
{
|
||||||
|
@ -389,7 +333,7 @@ class Note extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap contact’s nicks for a full mf2 h-card.
|
* Swap contact’s nicks for a full mf2 h-card.
|
||||||
*
|
*
|
||||||
* Take note that this method does two things, given @username (NOT [@username](URL)!)
|
* Take note that this method does two things, given @username (NOT [@username](URL)!)
|
||||||
* we try to create a fancy hcard from our contact info. If this is not possible
|
* we try to create a fancy hcard from our contact info. If this is not possible
|
||||||
|
@ -473,9 +417,6 @@ class Note extends Model
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass a note through the commonmark library.
|
|
||||||
*/
|
|
||||||
private function convertMarkdown(string $note): string
|
private function convertMarkdown(string $note): string
|
||||||
{
|
{
|
||||||
$config = [
|
$config = [
|
||||||
|
@ -500,9 +441,6 @@ class Note extends Model
|
||||||
return $markdownConverter->convert($note)->getContent();
|
return $markdownConverter->convert($note)->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Do a reverse geocode lookup of a `lat,lng` value.
|
|
||||||
*/
|
|
||||||
public function reverseGeoCode(float $latitude, float $longitude): string
|
public function reverseGeoCode(float $latitude, float $longitude): string
|
||||||
{
|
{
|
||||||
$latLng = $latitude . ',' . $longitude;
|
$latLng = $latitude . ',' . $longitude;
|
||||||
|
|
|
@ -17,36 +17,20 @@ class Place extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use Sluggable;
|
use Sluggable;
|
||||||
|
|
||||||
/**
|
public function getRouteKeyName(): string
|
||||||
* Get the route key for the model.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getRouteKeyName()
|
|
||||||
{
|
{
|
||||||
return 'slug';
|
return 'slug';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = ['name', 'slug'];
|
protected $fillable = ['name', 'slug'];
|
||||||
|
|
||||||
/**
|
/** @var array<string, string> */
|
||||||
* The attributes that should be cast.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'latitude' => 'float',
|
'latitude' => 'float',
|
||||||
'longitude' => 'float',
|
'longitude' => 'float',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the sluggable configuration array for this model.
|
|
||||||
*/
|
|
||||||
public function sluggable(): array
|
public function sluggable(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -57,12 +41,7 @@ class Place extends Model
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function notes(): HasMany
|
||||||
* Define the relationship with Notes.
|
|
||||||
*
|
|
||||||
* @return HasMany
|
|
||||||
*/
|
|
||||||
public function notes()
|
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Note');
|
return $this->hasMany('App\Models\Note');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,7 @@ class SyndicationTarget extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'uid',
|
'uid',
|
||||||
'name',
|
'name',
|
||||||
|
@ -28,11 +24,7 @@ class SyndicationTarget extends Model
|
||||||
'user_photo',
|
'user_photo',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are visible when serializing the model.
|
|
||||||
*
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
protected $visible = [
|
protected $visible = [
|
||||||
'uid',
|
'uid',
|
||||||
'name',
|
'name',
|
||||||
|
@ -40,21 +32,12 @@ class SyndicationTarget extends Model
|
||||||
'user',
|
'user',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The accessors to append to the model's array form.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
'service',
|
'service',
|
||||||
'user',
|
'user',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the service data as a single attribute.
|
|
||||||
*
|
|
||||||
* @return Attribute
|
|
||||||
*/
|
|
||||||
protected function service(): Attribute
|
protected function service(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::get(
|
return Attribute::get(
|
||||||
|
@ -66,11 +49,6 @@ class SyndicationTarget extends Model
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the user data as a single attribute.
|
|
||||||
*
|
|
||||||
* @vreturn Attribute
|
|
||||||
*/
|
|
||||||
protected function user(): Attribute
|
protected function user(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::get(
|
return Attribute::get(
|
||||||
|
|
|
@ -14,29 +14,15 @@ class Tag extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* We shall set a blacklist of non-modifiable model attributes.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
/**
|
public function notes(): BelongsToMany
|
||||||
* Define the relationship with notes.
|
|
||||||
*
|
|
||||||
* @return BelongsToMany
|
|
||||||
*/
|
|
||||||
public function notes()
|
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Note::class);
|
return $this->belongsToMany(Note::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function bookmarks(): BelongsToMany
|
||||||
* The bookmarks that belong to the tag.
|
|
||||||
*
|
|
||||||
* @return BelongsToMany
|
|
||||||
*/
|
|
||||||
public function bookmarks()
|
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('App\Models\Bookmark');
|
return $this->belongsToMany('App\Models\Bookmark');
|
||||||
}
|
}
|
||||||
|
@ -49,8 +35,9 @@ class Tag extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method actually normalizes a tag. That means lowercase-ing and
|
* Normalizes a tag.
|
||||||
* removing fancy diatric characters.
|
*
|
||||||
|
* That means convert to lowercase and removing fancy diatric characters.
|
||||||
*/
|
*/
|
||||||
public static function normalize(string $tag): string
|
public static function normalize(string $tag): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,21 +13,15 @@ class User extends Authenticatable
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name', 'password',
|
'name', 'password',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* The attributes that should be hidden for arrays.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'password', 'remember_token',
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,26 +20,13 @@ class WebMention extends Model
|
||||||
use FilterHtml;
|
use FilterHtml;
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* The database table used by the model.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'webmentions';
|
protected $table = 'webmentions';
|
||||||
|
|
||||||
/**
|
/** @var array<int, string> */
|
||||||
* We shall set a blacklist of non-modifiable model attributes.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
/**
|
public function commentable(): MorphTo
|
||||||
* Define the relationship.
|
|
||||||
*
|
|
||||||
* @return MorphTo
|
|
||||||
*/
|
|
||||||
public function commentable()
|
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class NoteObserver
|
||||||
/**
|
/**
|
||||||
* Listen to the Note created event.
|
* Listen to the Note created event.
|
||||||
*/
|
*/
|
||||||
public function created(Note $note)
|
public function created(Note $note): void
|
||||||
{
|
{
|
||||||
$text = Arr::get($note->getAttributes(), 'note');
|
$text = Arr::get($note->getAttributes(), 'note');
|
||||||
if ($text === null) {
|
if ($text === null) {
|
||||||
|
@ -36,7 +36,7 @@ class NoteObserver
|
||||||
/**
|
/**
|
||||||
* Listen to the Note updated event.
|
* Listen to the Note updated event.
|
||||||
*/
|
*/
|
||||||
public function updated(Note $note)
|
public function updated(Note $note): void
|
||||||
{
|
{
|
||||||
$text = Arr::get($note->getAttributes(), 'note');
|
$text = Arr::get($note->getAttributes(), 'note');
|
||||||
if ($text === null) {
|
if ($text === null) {
|
||||||
|
@ -60,7 +60,7 @@ class NoteObserver
|
||||||
/**
|
/**
|
||||||
* Listen to the Note deleting event.
|
* Listen to the Note deleting event.
|
||||||
*/
|
*/
|
||||||
public function deleting(Note $note)
|
public function deleting(Note $note): void
|
||||||
{
|
{
|
||||||
$note->tags()->detach();
|
$note->tags()->detach();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,8 @@ class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Bootstrap any application services.
|
* Bootstrap any application services.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Note::observe(NoteObserver::class);
|
Note::observe(NoteObserver::class);
|
||||||
|
|
||||||
|
@ -144,10 +142,8 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any application services.
|
* Register any application services.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register(): void
|
||||||
{
|
{
|
||||||
if ($this->app->environment('local', 'testing')) {
|
if ($this->app->environment('local', 'testing')) {
|
||||||
$this->app->register(DuskServiceProvider::class);
|
$this->app->register(DuskServiceProvider::class);
|
||||||
|
|
|
@ -7,16 +7,16 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The policy mappings for the application.
|
* The model to policy mappings for the application.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<class-string, class-string>
|
||||||
*/
|
*/
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any application authentication / authorization services.
|
* Register any authentication / authorization services.
|
||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,10 +12,8 @@ class BroadcastServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Bootstrap any application services.
|
* Bootstrap any application services.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Broadcast::routes();
|
Broadcast::routes();
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ use Illuminate\Support\Facades\Event;
|
||||||
class EventServiceProvider extends ServiceProvider
|
class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The event listener mappings for the application.
|
* The event to listener mappings for the application.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<class-string, array<int, class-string>>
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
Registered::class => [
|
Registered::class => [
|
||||||
|
@ -22,13 +22,9 @@ class EventServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any events for your application.
|
* Register any events for your application.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
parent::boot();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,8 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Bootstrap any application services.
|
* Bootstrap any application services.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
|
||||||
|
@ -28,10 +26,8 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||||
* Register the Horizon gate.
|
* Register the Horizon gate.
|
||||||
*
|
*
|
||||||
* This gate determines who can access Horizon in non-local environments.
|
* This gate determines who can access Horizon in non-local environments.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function gate()
|
protected function gate(): void
|
||||||
{
|
{
|
||||||
Gate::define('viewHorizon', function ($user) {
|
Gate::define('viewHorizon', function ($user) {
|
||||||
return $user->name === 'jonny';
|
return $user->name === 'jonny';
|
||||||
|
|
|
@ -11,46 +11,38 @@ use Illuminate\Support\Facades\Route;
|
||||||
class RouteServiceProvider extends ServiceProvider
|
class RouteServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This namespace is applied to your controller routes.
|
* The path to the "home" route for your application.
|
||||||
*
|
*
|
||||||
* In addition, it is set as the URL generator's root namespace.
|
* Typically, users are redirected here after authentication.
|
||||||
*
|
*
|
||||||
* @var string|null
|
* @var string
|
||||||
*/
|
*/
|
||||||
// protected $namespace = 'App\Http\Controllers';
|
public const HOME = '/admin';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define your route model bindings, pattern filters, etc.
|
* Define your route model bindings, pattern filters, and other route configuration.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(): void
|
||||||
{
|
{
|
||||||
$this->configureRateLimiting();
|
$this->configureRateLimiting();
|
||||||
|
|
||||||
$this->routes(function () {
|
$this->routes(function () {
|
||||||
Route::prefix('api')
|
Route::middleware('api')
|
||||||
->middleware('api')
|
->prefix('api')
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/api.php'));
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
Route::middleware('web')
|
Route::middleware('web')
|
||||||
->namespace($this->namespace)
|
|
||||||
->group(base_path('routes/web.php'));
|
->group(base_path('routes/web.php'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the rate limiters for the application.
|
* Configure the rate limiters for the application.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
protected function configureRateLimiting()
|
protected function configureRateLimiting(): void
|
||||||
{
|
{
|
||||||
RateLimiter::for('api', function (Request $request) {
|
RateLimiter::for('api', function (Request $request) {
|
||||||
return Limit::perMinute(60);
|
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,14 @@ declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
class ActivityStreamsService
|
class ActivityStreamsService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return the relevant data to an AS2.0 request to the root path.
|
* Return the relevant data to an AS2.0 request to the root path.
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
*/
|
||||||
public function siteOwnerResponse()
|
public function siteOwnerResponse(): Response
|
||||||
{
|
{
|
||||||
$data = json_encode([
|
$data = json_encode([
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
|
@ -28,10 +27,8 @@ class ActivityStreamsService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the relevant data to an AS2.0 request for a particular note.
|
* Return the relevant data to an AS2.0 request for a particular note.
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
*/
|
||||||
public function singleNoteResponse(Note $note)
|
public function singleNoteResponse(Note $note): Response
|
||||||
{
|
{
|
||||||
$data = json_encode([
|
$data = json_encode([
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
|
|
|
@ -19,8 +19,6 @@ class BookmarkService extends Service
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new Bookmark.
|
* Create a new Bookmark.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
public function create(array $request, ?string $client = null): Bookmark
|
public function create(array $request, ?string $client = null): Bookmark
|
||||||
{
|
{
|
||||||
|
@ -74,7 +72,6 @@ class BookmarkService extends Service
|
||||||
/**
|
/**
|
||||||
* Given a URL, attempt to save it to the Internet Archive.
|
* Given a URL, attempt to save it to the Internet Archive.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @throws InternetArchiveException
|
* @throws InternetArchiveException
|
||||||
*/
|
*/
|
||||||
public function getArchiveLink(string $url): string
|
public function getArchiveLink(string $url): string
|
||||||
|
|
|
@ -12,8 +12,6 @@ class LikeService extends Service
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new Like.
|
* Create a new Like.
|
||||||
*
|
|
||||||
* @return Like $like
|
|
||||||
*/
|
*/
|
||||||
public function create(array $request, ?string $client = null): Like
|
public function create(array $request, ?string $client = null): Like
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,8 +11,6 @@ class HCardService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a Place from h-card data, return the URL.
|
* Create a Place from h-card data, return the URL.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
public function process(array $request): string
|
public function process(array $request): string
|
||||||
{
|
{
|
||||||
|
@ -28,8 +26,7 @@ class HCardService
|
||||||
$data['latitude'] = Arr::get($request, 'latitude');
|
$data['latitude'] = Arr::get($request, 'latitude');
|
||||||
$data['longitude'] = Arr::get($request, 'longitude');
|
$data['longitude'] = Arr::get($request, 'longitude');
|
||||||
}
|
}
|
||||||
$place = resolve(PlaceService::class)->createPlace($data);
|
|
||||||
|
|
||||||
return $place->longurl;
|
return resolve(PlaceService::class)->createPlace($data)->longurl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,7 @@ use Illuminate\Support\Arr;
|
||||||
class HEntryService
|
class HEntryService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create the relavent model from some h-entry data.
|
* Create the relevant model from some h-entry data.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
* @param string|null $client The micropub client that made the request
|
|
||||||
*/
|
*/
|
||||||
public function process(array $request, ?string $client = null): ?string
|
public function process(array $request, ?string $client = null): ?string
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Services\Micropub;
|
||||||
use App\Models\Media;
|
use App\Models\Media;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
@ -14,11 +15,8 @@ class UpdateService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Process a micropub request to update an entry.
|
* Process a micropub request to update an entry.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
*/
|
||||||
public function process(array $request)
|
public function process(array $request): JsonResponse
|
||||||
{
|
{
|
||||||
$urlPath = parse_url(Arr::get($request, 'url'), PHP_URL_PATH);
|
$urlPath = parse_url(Arr::get($request, 'url'), PHP_URL_PATH);
|
||||||
|
|
||||||
|
@ -42,10 +40,10 @@ class UpdateService
|
||||||
//got the note, are we dealing with a “replace” request?
|
//got the note, are we dealing with a “replace” request?
|
||||||
if (Arr::get($request, 'replace')) {
|
if (Arr::get($request, 'replace')) {
|
||||||
foreach (Arr::get($request, 'replace') as $property => $value) {
|
foreach (Arr::get($request, 'replace') as $property => $value) {
|
||||||
if ($property == 'content') {
|
if ($property === 'content') {
|
||||||
$note->note = $value[0];
|
$note->note = $value[0];
|
||||||
}
|
}
|
||||||
if ($property == 'syndication') {
|
if ($property === 'syndication') {
|
||||||
foreach ($value as $syndicationURL) {
|
foreach ($value as $syndicationURL) {
|
||||||
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
||||||
$note->facebook_url = $syndicationURL;
|
$note->facebook_url = $syndicationURL;
|
||||||
|
@ -69,7 +67,7 @@ class UpdateService
|
||||||
//how about “add”
|
//how about “add”
|
||||||
if (Arr::get($request, 'add')) {
|
if (Arr::get($request, 'add')) {
|
||||||
foreach (Arr::get($request, 'add') as $property => $value) {
|
foreach (Arr::get($request, 'add') as $property => $value) {
|
||||||
if ($property == 'syndication') {
|
if ($property === 'syndication') {
|
||||||
foreach ($value as $syndicationURL) {
|
foreach ($value as $syndicationURL) {
|
||||||
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
||||||
$note->facebook_url = $syndicationURL;
|
$note->facebook_url = $syndicationURL;
|
||||||
|
@ -82,7 +80,7 @@ class UpdateService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($property == 'photo') {
|
if ($property === 'photo') {
|
||||||
foreach ($value as $photoURL) {
|
foreach ($value as $photoURL) {
|
||||||
if (Str::startsWith($photoURL, 'https://')) {
|
if (Str::startsWith($photoURL, 'https://')) {
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
|
|
|
@ -18,8 +18,6 @@ class NoteService extends Service
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new note.
|
* Create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
public function create(array $request, ?string $client = null): Note
|
public function create(array $request, ?string $client = null): Note
|
||||||
{
|
{
|
||||||
|
@ -66,8 +64,6 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the published time from the request to create a new note.
|
* Get the published time from the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getPublished(array $request): ?string
|
private function getPublished(array $request): ?string
|
||||||
{
|
{
|
||||||
|
@ -84,13 +80,11 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the location data from the request to create a new note.
|
* Get the location data from the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getLocation(array $request): ?string
|
private function getLocation(array $request): ?string
|
||||||
{
|
{
|
||||||
$location = Arr::get($request, 'properties.location.0') ?? Arr::get($request, 'location');
|
$location = Arr::get($request, 'properties.location.0') ?? Arr::get($request, 'location');
|
||||||
if (is_string($location) && substr($location, 0, 4) == 'geo:') {
|
if (is_string($location) && str_starts_with($location, 'geo:')) {
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/([0-9\.\-]+)/',
|
'/([0-9\.\-]+)/',
|
||||||
$location,
|
$location,
|
||||||
|
@ -105,8 +99,6 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the checkin data from the request to create a new note. This will be a Place.
|
* Get the checkin data from the request to create a new note. This will be a Place.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getCheckin(array $request): ?Place
|
private function getCheckin(array $request): ?Place
|
||||||
{
|
{
|
||||||
|
@ -150,12 +142,10 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Swarm URL from the syndication data in the request to create a new note.
|
* Get the Swarm URL from the syndication data in the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getSwarmUrl(array $request): ?string
|
private function getSwarmUrl(array $request): ?string
|
||||||
{
|
{
|
||||||
if (stristr(Arr::get($request, 'properties.syndication.0', ''), 'swarmapp')) {
|
if (str_contains(Arr::get($request, 'properties.syndication.0', ''), 'swarmapp')) {
|
||||||
return Arr::get($request, 'properties.syndication.0');
|
return Arr::get($request, 'properties.syndication.0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +154,6 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the syndication targets from the request to create a new note.
|
* Get the syndication targets from the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getSyndicationTargets(array $request): array
|
private function getSyndicationTargets(array $request): array
|
||||||
{
|
{
|
||||||
|
@ -187,8 +175,6 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the media URLs from the request to create a new note.
|
* Get the media URLs from the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getMedia(array $request): array
|
private function getMedia(array $request): array
|
||||||
{
|
{
|
||||||
|
@ -216,8 +202,6 @@ class NoteService extends Service
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Instagram photo URL from the request to create a new note.
|
* Get the Instagram photo URL from the request to create a new note.
|
||||||
*
|
|
||||||
* @param array $request Data from request()->all()
|
|
||||||
*/
|
*/
|
||||||
private function getInstagramUrl(array $request): ?string
|
private function getInstagramUrl(array $request): ?string
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,8 +37,6 @@ class PlaceService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a place from a h-card checkin, for example from OwnYourSwarm.
|
* Create a place from a h-card checkin, for example from OwnYourSwarm.
|
||||||
*
|
|
||||||
* @param array
|
|
||||||
*/
|
*/
|
||||||
public function createPlaceFromCheckin(array $checkin): Place
|
public function createPlaceFromCheckin(array $checkin): Place
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,6 @@ class TokenService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Generate a JWT token.
|
* Generate a JWT token.
|
||||||
*
|
|
||||||
* @param array The data to be encoded
|
|
||||||
* @return string The signed token
|
|
||||||
*/
|
*/
|
||||||
public function getNewToken(array $data): string
|
public function getNewToken(array $data): string
|
||||||
{
|
{
|
||||||
|
@ -36,9 +33,6 @@ class TokenService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the token signature is valid.
|
* Check the token signature is valid.
|
||||||
*
|
|
||||||
* @param string The token
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function validateToken(string $bearerToken): Token
|
public function validateToken(string $bearerToken): Token
|
||||||
{
|
{
|
||||||
|
|
2
artisan
2
artisan
|
@ -11,7 +11,7 @@ define('LARAVEL_START', microtime(true));
|
||||||
| Composer provides a convenient, automatically generated class loader
|
| Composer provides a convenient, automatically generated class loader
|
||||||
| for our application. We just need to utilize it! We'll require it
|
| for our application. We just need to utilize it! We'll require it
|
||||||
| into the script here so that we do not have to worry about the
|
| into the script here so that we do not have to worry about the
|
||||||
| loading of any our classes "manually". Feels great to relax.
|
| loading of any of our classes manually. It's great to relax.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ return [
|
||||||
| Application Long URL
|
| Application Long URL
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The short URL for the application
|
| The long URL for the application
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -191,7 +191,9 @@ return [
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Font Link
|
| Font Link
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
| Which URL should the app load custom fonts from
|
| Which URL should the app load custom fonts from
|
||||||
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'font_link' => env('FONT_LINK'),
|
'font_link' => env('FONT_LINK'),
|
||||||
|
|
|
@ -84,12 +84,16 @@ return [
|
||||||
| considered valid. This security feature keeps tokens short-lived so
|
| considered valid. This security feature keeps tokens short-lived so
|
||||||
| they have less time to be guessed. You may change this as needed.
|
| they have less time to be guessed. You may change this as needed.
|
||||||
|
|
|
|
||||||
|
| The throttle setting is the number of seconds a user must wait before
|
||||||
|
| generating more password reset tokens. This prevents the user from
|
||||||
|
| quickly generating a very large amount of password reset tokens.
|
||||||
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'passwords' => [
|
'passwords' => [
|
||||||
'users' => [
|
'users' => [
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
'table' => 'password_resets',
|
'table' => 'password_reset_tokens',
|
||||||
'expire' => 60,
|
'expire' => 60,
|
||||||
'throttle' => 60,
|
'throttle' => 60,
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,7 +28,7 @@ return [
|
||||||
| sending an e-mail. You will specify which one you are using for your
|
| sending an e-mail. You will specify which one you are using for your
|
||||||
| mailers below. You are free to add additional mailers as required.
|
| mailers below. You are free to add additional mailers as required.
|
||||||
|
|
|
|
||||||
| Supported: "smtp", "sendmail", "mailgun", "ses",
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||||
| "postmark", "log", "array", "failover"
|
| "postmark", "log", "array", "failover"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
@ -51,10 +51,16 @@ return [
|
||||||
|
|
||||||
'mailgun' => [
|
'mailgun' => [
|
||||||
'transport' => 'mailgun',
|
'transport' => 'mailgun',
|
||||||
|
// 'client' => [
|
||||||
|
// 'timeout' => 5,
|
||||||
|
// ],
|
||||||
],
|
],
|
||||||
|
|
||||||
'postmark' => [
|
'postmark' => [
|
||||||
'transport' => 'postmark',
|
'transport' => 'postmark',
|
||||||
|
// 'client' => [
|
||||||
|
// 'timeout' => 5,
|
||||||
|
// ],
|
||||||
],
|
],
|
||||||
|
|
||||||
'sendmail' => [
|
'sendmail' => [
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Article;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Article>
|
||||||
|
*/
|
||||||
class ArticleFactory extends Factory
|
class ArticleFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class ArticleFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'titleurl' => $this->faker->slug(3),
|
'titleurl' => $this->faker->slug(3),
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Bookmark;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Bookmark>
|
||||||
|
*/
|
||||||
class BookmarkFactory extends Factory
|
class BookmarkFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class BookmarkFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = Carbon::now()->subDays(rand(5, 15));
|
$now = Carbon::now()->subDays(rand(5, 15));
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Contact;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Contact>
|
||||||
|
*/
|
||||||
class ContactFactory extends Factory
|
class ContactFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class ContactFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'nick' => mb_strtolower($this->faker->firstName),
|
'nick' => mb_strtolower($this->faker->firstName),
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Like;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Like>
|
||||||
|
*/
|
||||||
class LikeFactory extends Factory
|
class LikeFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class LikeFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = Carbon::now()->subDays(rand(5, 15));
|
$now = Carbon::now()->subDays(rand(5, 15));
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Media;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Media>
|
||||||
|
*/
|
||||||
class MediaFactory extends Factory
|
class MediaFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class MediaFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'path' => 'media/' . $this->faker->uuid . '.jpg',
|
'path' => 'media/' . $this->faker->uuid . '.jpg',
|
||||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
||||||
use App\Models\MicropubClient;
|
use App\Models\MicropubClient;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MicropubClient>
|
||||||
|
*/
|
||||||
class MicropubClientFactory extends Factory
|
class MicropubClientFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +20,9 @@ class MicropubClientFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'client_url' => $this->faker->url,
|
'client_url' => $this->faker->url,
|
||||||
|
|
|
@ -7,6 +7,9 @@ use Exception;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Note>
|
||||||
|
*/
|
||||||
class NoteFactory extends Factory
|
class NoteFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,11 +22,11 @@ class NoteFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
$now = Carbon::now()->subDays(random_int(5, 15));
|
$now = Carbon::now()->subDays(random_int(5, 15));
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Place>
|
||||||
|
*/
|
||||||
class PlaceFactory extends Factory
|
class PlaceFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +20,9 @@ class PlaceFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->company,
|
'name' => $this->faker->company,
|
||||||
|
|
|
@ -14,7 +14,7 @@ class SyndicationTargetFactory extends Factory
|
||||||
*
|
*
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'uid' => $this->faker->url,
|
'uid' => $this->faker->url,
|
||||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Tag>
|
||||||
|
*/
|
||||||
class TagFactory extends Factory
|
class TagFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +20,9 @@ class TagFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'tag' => $this->faker->word,
|
'tag' => $this->faker->word,
|
||||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
class UserFactory extends Factory
|
class UserFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +21,9 @@ class UserFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->name,
|
'name' => $this->faker->name,
|
||||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
||||||
use App\Models\WebMention;
|
use App\Models\WebMention;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\WebMention>
|
||||||
|
*/
|
||||||
class WebMentionFactory extends Factory
|
class WebMentionFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +20,9 @@ class WebMentionFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'source' => $this->faker->url,
|
'source' => $this->faker->url,
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateArticlesTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
if (! Schema::hasTable('articles')) {
|
|
||||||
Schema::create('articles', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('titleurl', 50)->unique();
|
|
||||||
$table->string('url', 120)->nullable();
|
|
||||||
$table->string('title');
|
|
||||||
$table->longText('main');
|
|
||||||
$table->tinyInteger('published')->default(0);
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('articles');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateNotesTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
if (! Schema::hasTable('notes')) {
|
|
||||||
Schema::create('notes', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->text('note');
|
|
||||||
$table->string('in_reply_to')->nullable();
|
|
||||||
$table->string('shorturl', 20)->nullable();
|
|
||||||
$table->string('location')->nullable();
|
|
||||||
$table->tinyInteger('photo')->nullable();
|
|
||||||
$table->string('tweet_id')->nullable();
|
|
||||||
$table->string('client_id')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('notes');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateTagsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('tags', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('tag');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('tags');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateNoteTagTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('note_tag', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->integer('note_id')->unsigned();
|
|
||||||
$table->integer('tag_id')->unsigned();
|
|
||||||
$table->foreign('note_id')->references('id')->on('notes');
|
|
||||||
$table->foreign('tag_id')->references('id')->on('tags');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('note_tag');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateContactsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('contacts', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('nick');
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('homepage')->nullable();
|
|
||||||
$table->string('twitter')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('contacts');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateWebMentionsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('webmentions', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('source');
|
|
||||||
$table->string('target');
|
|
||||||
$table->integer('commentable_id')->nullable();
|
|
||||||
$table->string('commentable_type')->nullable();
|
|
||||||
$table->string('type')->nullable();
|
|
||||||
$table->text('content')->nullable();
|
|
||||||
$table->tinyInteger('verified')->default(1);
|
|
||||||
$table->timestamps();
|
|
||||||
$table->softDeletes();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('webmentions');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreateClientsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('clients', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('client_url');
|
|
||||||
$table->string('client_name');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('clients');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateMediaTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('media', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->morphs('model');
|
|
||||||
$table->string('collection_name');
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('file_name');
|
|
||||||
$table->string('disk');
|
|
||||||
$table->unsignedInteger('size');
|
|
||||||
$table->text('manipulations');
|
|
||||||
$table->text('custom_properties');
|
|
||||||
$table->unsignedInteger('order_column')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('media');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class CreatePlacesTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('places', function (Blueprint $table) {
|
|
||||||
$table->increments('id');
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('slug')->unique();
|
|
||||||
$table->text('description')->nullable();
|
|
||||||
$table->text('location');
|
|
||||||
$table->text('polygon')->nullable();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::drop('places');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class AddPlaceRelationToNotes extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('notes', function (Blueprint $table) {
|
|
||||||
$table->integer('place_id')->unsigned()->nullable();
|
|
||||||
$table->foreign('place_id')->references('id')->on('places');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('notes', function (Blueprint $table) {
|
|
||||||
$table->dropForeign('notes_place_id_foreign');
|
|
||||||
$table->dropColumn('place_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class AddJsonbMf2ColumnToWebmentionsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('webmentions', function (Blueprint $table) {
|
|
||||||
$table->jsonb('mf2')->nullable();
|
|
||||||
$table->index(['mf2']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('webmentions', function (Blueprint $table) {
|
|
||||||
$table->dropIndex(['mf2']);
|
|
||||||
$table->dropColumn('mf2');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue