mirror of
https://github.com/anonaddy/anonaddy
synced 2026-04-26 01:25:06 +02:00
38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ShowBlocklistController extends Controller
|
|
{
|
|
public function index(Request $request): Response
|
|
{
|
|
$validated = $request->validate([
|
|
'search' => 'nullable|string|max:100|min:1',
|
|
]);
|
|
|
|
$query = user()
|
|
->blockedSenders()
|
|
->select(['id', 'user_id', 'type', 'value', 'blocked', 'last_blocked', 'created_at'])
|
|
->latest();
|
|
|
|
if (isset($validated['search'])) {
|
|
$searchTerm = strtolower($validated['search']);
|
|
$query->where(function ($q) use ($searchTerm) {
|
|
$q->whereRaw('LOWER(value) LIKE ?', ['%'.$searchTerm.'%'])
|
|
->orWhereRaw('LOWER(type) LIKE ?', ['%'.$searchTerm.'%']);
|
|
});
|
|
}
|
|
|
|
$blockedSenders = $query->get();
|
|
|
|
return Inertia::render('Blocklist/Index', [
|
|
'initialRows' => $blockedSenders,
|
|
'search' => $validated['search'] ?? null,
|
|
]);
|
|
}
|
|
}
|