2023-04-11 21:16:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Note;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\View\View;
|
|
|
|
|
2023-07-28 11:48:07 +01:00
|
|
|
/**
|
|
|
|
* @psalm-suppress UnusedClass
|
|
|
|
*/
|
2023-04-11 21:16:06 +01:00
|
|
|
class SearchController extends Controller
|
|
|
|
{
|
|
|
|
public function search(Request $request): View
|
|
|
|
{
|
|
|
|
$search = $request->input('q');
|
|
|
|
|
|
|
|
$notes = Note::search($search)
|
|
|
|
->paginate();
|
|
|
|
|
|
|
|
/** @var Note $note */
|
|
|
|
foreach ($notes as $note) {
|
2023-11-25 16:08:07 +00:00
|
|
|
$note->load('place', 'media', 'client')
|
|
|
|
->loadCount(['webmentions AS replies' => function ($query) {
|
|
|
|
$query->where('type', 'in-reply-to');
|
|
|
|
}])
|
|
|
|
->loadCount(['webmentions AS likes' => function ($query) {
|
|
|
|
$query->where('type', 'like-of');
|
|
|
|
}])
|
|
|
|
->loadCount(['webmentions AS reposts' => function ($query) {
|
|
|
|
$query->where('type', 'repost-of');
|
|
|
|
}]);
|
2023-04-11 21:16:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return view('search', compact('search', 'notes'));
|
|
|
|
}
|
|
|
|
}
|