This commit is contained in:
deploy-bot committed 2026-12-05 19:00:02 +00:00
commit 4769402b1b
298 files changed
+20934

No files matched your search

+178
View File
@@ -0,0 +1,178 @@
<?php
namespace IriksIT\Manager\Modules\Leads;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use IriksIT\Manager\Modules\Statistics\VisitRecorder;
use IriksIT\Manager\Support\Leads\Intake;
use IriksIT\Manager\Support\Leads\Phone;
use IriksIT\Manager\Support\Leads\Report;
use IriksIT\Manager\Support\Login\Turnstile;
use IriksIT\Manager\Support\ModuleRegistry;
use IriksIT\Manager\Support\UserAgent;
/**
* The one place the forms of the public site are sent to (`manager.leads.form`). A form is a name (the last part of the address) with a
* kind and the fields it requires; the questions and moments a visitor may tap are the site's own list, anything else is dropped.
*
* A form never tells a sender that it was taken for spam: whatever the screening thinks, the visitor gets the normal thank-you. A program
* that fills the honeypot field gets it too, and nothing is stored or mailed.
*/
class LeadFormController
{
public function store(Request $request, Intake $intake, string $form): JsonResponse|RedirectResponse
{
$definition = (array) (config('manager.leads.form.forms')[$form] ?? abort(404));
$kind = (string) ($definition['kind'] ?? $form);
// Real visitors never see or fill the honeypot.
$honeypot = (string) config('manager.leads.form.honeypot', 'website');
if ($honeypot !== '' && $request->filled($honeypot)) {
return $this->thanks($request);
}
$attributes = $this->validated($request, (array) ($definition['require'] ?? ['name']));
// After the fields are right, so the visitor fixes those first: a token works once.
if (config('manager.leads.form.turnstile', true) && Turnstile::configured() && ! Turnstile::passes($request->string('turnstile')->limit(2048, '')->toString(), (string) $request->ip())) {
throw ValidationException::withMessages(['turnstile' => __('Prove you are not a program, then send it again.')]);
}
$intake->take(
[...$attributes, 'kind' => $kind, 'about' => $kind !== 'callback' && $request->string('about')->toString() === 'other' ? 'other' : 'job', 'page' => $this->pageOf($request), 'answers' => $this->answers($request, $kind)],
Intake::secondsOpen($request->string('form_token')->toString()),
(string) $request->ip(),
(string) $request->userAgent(),
);
return $this->thanks($request);
}
/** A tap on the phone number or the WhatsApp button, counted for the page it was on. */
public function tap(Request $request): JsonResponse
{
$data = $request->validate(['kind' => ['required', 'in:call,whatsapp'], 'path' => ['required', 'string', 'max:255']]);
$path = parse_url($data['path'], PHP_URL_PATH) ?: '/';
// A program is no caller, and where the statistics are on, only a page that exists counts (nobody can fill the list with made-up addresses).
if ((new UserAgent((string) $request->userAgent()))->isBot()) {
return response()->json(['ok' => true], 201);
}
if (app(ModuleRegistry::class)->enabled('statistics') && ($path = app(VisitRecorder::class)->pathOf($path)) === null) {
return response()->json(['ok' => true], 201);
}
Report::tap($data['kind'], $path);
return response()->json(['ok' => true], 201);
}
/** A signed moment for a form that is built by script: sent back with the form, it tells how long the form was open. */
public function token(): JsonResponse
{
return response()->json(['token' => Intake::formToken()])->header('Cache-Control', 'no-store');
}
private function thanks(Request $request): JsonResponse|RedirectResponse
{
if ($request->expectsJson()) {
return response()->json(['ok' => true], 201);
}
$to = config('manager.leads.form.thanks');
return ($to ? redirect($to) : back())->with('manager_lead_sent', true);
}
/**
* @param list<string> $require `name`, `phone`, `email`, `contact` (one box: with an @ a mail address, else a phone number), `message`, `location`, `subject`
* @return array<string, mixed>
*/
private function validated(Request $request, array $require): array
{
$needs = fn (string $field) => in_array($field, $require, true) ? ['required'] : ['nullable'];
$request->validate([
'name' => ['required', 'string', 'max:120'],
'contact' => [...$needs('contact'), 'string', 'max:255'],
'phone' => [...$needs('phone'), 'string', 'max:40'],
'email' => [...$needs('email'), 'email', 'max:255'],
'message' => [...$needs('message'), 'string', 'max:5000'],
'location' => [...$needs('location'), 'string', 'max:120'],
'about' => ['nullable', 'in:job,other'],
'prefers' => ['nullable', 'in:phone,whatsapp,email'],
'subject' => [...$needs('subject'), 'string', 'max:255'],
'subject_id' => ['nullable', 'integer'],
]);
$phone = $request->string('phone')->trim()->toString();
$email = $request->string('email')->trim()->toString();
$contact = $request->string('contact')->trim()->toString();
if ($contact !== '') {
if (str_contains($contact, '@')) {
filter_var($contact, FILTER_VALIDATE_EMAIL) !== false || throw ValidationException::withMessages(['contact' => __('This does not look like a mail address.')]);
$email = $contact;
} else {
$phone = $contact;
}
}
if ($phone !== '' && Phone::international($phone) === null) {
throw ValidationException::withMessages([$contact !== '' ? 'contact' : 'phone' => __('This does not look like a phone number.')]);
}
if ($phone === '' && $email === '') {
throw ValidationException::withMessages([in_array('contact', $require, true) ? 'contact' : 'phone' => __('Give a phone number or a mail address, so we can answer.')]);
}
return [
'name' => $request->string('name')->trim()->toString(),
'phone' => $phone !== '' ? $phone : null,
'email' => $email !== '' ? $email : null,
'prefers' => $request->filled('prefers') ? $request->string('prefers')->toString() : null,
'message' => $request->filled('message') ? $request->string('message')->trim()->toString() : null,
'location' => $request->filled('location') ? $request->string('location')->trim()->toString() : null,
'subject' => $request->filled('subject') ? $request->string('subject')->trim()->toString() : null,
'subject_id' => $request->filled('subject_id') ? $request->integer('subject_id') : null,
];
}
/**
* What was tapped: only the questions and the moments the site itself offers.
*
* @return array<string, string>
*/
private function answers(Request $request, string $kind): array
{
$answers = [];
$moment = $request->string('moment')->toString();
$moments = (array) config('manager.leads.form.moments', []);
if ($kind === 'callback' && in_array($moment, $moments, true)) {
$answers[__('When suits you?')] = $moment;
}
foreach ((array) config('manager.leads.form.questions', []) as $key => $question) {
$answer = $request->string("answers.{$key}")->toString();
if ($answer !== '' && in_array($answer, (array) ($question['options'] ?? []), true)) {
$answers[(string) ($question['label'] ?? $key)] = $answer;
}
}
return $answers;
}
/** The page the form was on, as a path of this site. */
private function pageOf(Request $request): ?string
{
$path = parse_url((string) $request->headers->get('referer'), PHP_URL_PATH);
return is_string($path) && $path !== '' ? mb_substr($path, 0, 300) : null;
}
}
+209
View File
@@ -0,0 +1,209 @@
<?php
namespace IriksIT\Manager\Modules\Leads;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
use IriksIT\Manager\Models\Lead;
use IriksIT\Manager\Models\LeadBlock;
use IriksIT\Manager\Support\Leads\Intake;
use IriksIT\Manager\Support\Leads\Phone;
use IriksIT\Manager\Support\Leads\Report;
/**
* The requests. Whoever may see them sees what is waiting and what was handled, and calls, apps or mails back. Whoever may manage
* them also sees what the screening kept away ("other" and spam), with the reasons, and can move requests or block senders.
*/
class LeadsController
{
private const VIEWS = ['waiting', 'handled'];
public function index(Request $request, Report $report): JsonResponse
{
$manages = Gate::allows('leads.manage');
$view = $request->string('view')->toString();
$view = in_array($view, $manages ? [...self::VIEWS, Lead::OTHER, Lead::SPAM] : self::VIEWS, true) ? $view : 'waiting';
$query = Lead::query()->latest('id');
match ($view) {
'waiting' => $query->waiting(),
'handled' => $query->handled(),
default => $query->where('folder', $view),
};
return response()->json([
'view' => $view,
'items' => $query->limit(200)->get()->map(fn (Lead $lead) => $this->present($lead, $manages))->values(),
'counts' => [
'waiting' => Lead::query()->waiting()->count(),
'handled' => Lead::query()->handled()->count(),
// How much was kept away; the folders themselves are only for who manages.
'other' => Lead::query()->where('folder', Lead::OTHER)->count(),
'spam' => Lead::query()->where('folder', Lead::SPAM)->count(),
],
'open' => $request->integer('open') ?: null,
'blocks' => $manages ? LeadBlock::query()->latest('id')->get()->map(fn (LeadBlock $block) => [
'id' => $block->id, 'type' => $block->type, 'value' => $block->value, 'reason' => $block->reason, 'expires_at' => $block->expires_at?->toIso8601String(),
])->values() : null,
// What the forms and the contact buttons brought in, the last 90 days.
'report' => $manages ? $report->over(90) : null,
'can' => ['handle' => Gate::allows('leads.handle'), 'manage' => $manages, 'delete' => Gate::allows('leads.delete')],
]);
}
/** The first time a request is opened: it is no longer new. */
public function opened(int $lead): JsonResponse
{
$lead = Lead::findOrFail($lead);
$lead->opened_at ??= now();
$lead->save();
return response()->json(['ok' => true]);
}
/** "Handled", and back; with whether it became a job, when that is said. */
public function handled(Request $request, int $lead): JsonResponse
{
$lead = Lead::findOrFail($lead);
$request->validate(['handled' => ['required', 'boolean'], 'outcome' => ['nullable', Rule::in([Lead::WON, Lead::LOST])]]);
$handled = $request->boolean('handled');
$lead->update([
'handled_at' => $handled ? ($lead->handled_at ?? now()) : null,
'outcome' => $handled && $request->filled('outcome') ? $request->string('outcome')->toString() : ($handled ? $lead->outcome : null),
'opened_at' => $lead->opened_at ?? now(),
]);
return response()->json($this->present($lead->refresh(), Gate::allows('leads.manage')));
}
/** A note of the owner to themselves. */
public function note(Request $request, int $lead): JsonResponse
{
$lead = Lead::findOrFail($lead);
$request->validate(['text' => ['required', 'string', 'max:2000']]);
$lead->update(['notes' => [
...($lead->notes ?? []),
['at' => now()->format('Y-m-d H:i:s'), 'by' => Auth::user()?->name, 'text' => $request->string('text')->trim()->toString()],
]]);
return response()->json($this->present($lead->refresh(), Gate::allows('leads.manage')), 201);
}
/** Moves a request to another folder: the screening made the wrong call, or let something through. */
public function folder(Request $request, Intake $intake, int $lead): JsonResponse
{
$lead = Lead::findOrFail($lead);
$request->validate(['folder' => ['required', Rule::in(Lead::FOLDERS)]]);
$folder = $request->string('folder')->toString();
$was = $lead->folder;
$lead->update(['folder' => $folder, 'reasons' => [...($lead->reasons ?? []), 'Moved by hand from '.$was.' to '.$folder]]);
// A real request after all: the owner hears about it like about any new one.
if ($folder === Lead::INBOX && $was !== Lead::INBOX && $lead->notified_at === null) {
$intake->tellTheOwner($lead);
}
return response()->json($this->present($lead->refresh(), true));
}
/** Keeps a sender out: what they send from now on goes to the spam folder. */
public function block(Request $request, int $lead): JsonResponse
{
$lead = Lead::findOrFail($lead);
$request->validate([
'type' => ['required', Rule::in(LeadBlock::TYPES)],
'days' => ['nullable', 'integer', 'min:1', 'max:3650'],
'reason' => ['nullable', 'string', 'max:255'],
]);
$type = $request->string('type')->toString();
$email = mb_strtolower((string) $lead->email);
$value = match ($type) {
LeadBlock::EMAIL => $email,
LeadBlock::DOMAIN => substr((string) strrchr($email, '@'), 1),
LeadBlock::PHONE => (string) Phone::international((string) $lead->phone),
default => (string) $lead->ip,
};
if ($value === '') {
return response()->json(['message' => __('This request has nothing of that kind to block.')], 422);
}
// Half the country mails from these: blocking one would keep customers out.
if ($type === LeadBlock::DOMAIN && in_array($value, LeadBlock::SHARED_DOMAINS, true)) {
return response()->json(['message' => __('Everyone uses :domain: block the mail address instead of the whole domain.', ['domain' => $value])], 422);
}
$block = LeadBlock::query()->updateOrCreate(['type' => $type, 'value' => $value], [
'reason' => $request->filled('reason') ? $request->string('reason')->toString() : null,
'expires_at' => $request->filled('days') ? now()->addDays($request->integer('days')) : null,
'user_id' => Auth::id(),
'user_name' => Auth::user()?->name,
]);
return response()->json(['id' => $block->id, 'type' => $type, 'value' => $value], 201);
}
public function unblock(int $block): JsonResponse
{
LeadBlock::findOrFail($block)->delete();
return response()->json(['ok' => true]);
}
public function destroy(int $lead): JsonResponse
{
Lead::findOrFail($lead)->delete();
return response()->json(['ok' => true]);
}
/**
* A request as the screen shows it. The reasons of the screening, the address it came from and where the visit came from are
* only for whoever manages the requests.
*
* @return array<string, mixed>
*/
private function present(Lead $lead, bool $manages): array
{
$digits = $lead->phone ? Phone::international($lead->phone) : null;
return [
'id' => $lead->id,
'kind' => $lead->kindLabel(),
'subject' => $lead->aboutLine(),
'name' => $lead->name,
'phone' => $lead->phone,
'email' => $lead->email,
'prefers' => $lead->prefers,
'message' => $lead->message,
'answers' => $lead->answers ?? [],
'location' => $lead->location,
'page' => $lead->page,
'call_link' => $digits ? 'tel:+'.$digits : null,
'whatsapp_link' => $digits ? 'https://wa.me/'.$digits : null,
'mail_link' => $lead->email ? 'mailto:'.$lead->email : null,
'is_new' => $lead->opened_at === null,
'handled' => $lead->handled_at !== null,
'outcome' => $lead->outcome,
'notes' => $lead->notes ?? [],
'created_at' => $lead->created_at?->toIso8601String(),
'notify_failed' => $lead->notify_failed,
...($manages ? [
'folder' => $lead->folder,
'reasons' => $lead->reasons ?? [],
'source' => trim(($lead->channel ?? '').($lead->source ? ': '.$lead->source : '')) ?: null,
'ip' => $lead->ip,
] : []),
];
}
}
+92
View File
@@ -0,0 +1,92 @@
<?php
namespace IriksIT\Manager\Modules\Leads;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use IriksIT\Manager\Console\LeadsPruneCommand;
use IriksIT\Manager\Modules\BaseModule;
use IriksIT\Manager\Support\Names;
use IriksIT\Manager\Support\Permission;
/**
* The requests of visitors (callback requests, questions, quotes, a contact form): stored, screened into folders, handled and kept for
* a while. The forms are the site's own and call `Support\Leads\Intake`. With a feature `leads` in `manager.features`, one switch
* turns the module on and off.
*/
class LeadsModule extends BaseModule
{
public function key(): string
{
return 'leads';
}
public function label(): string
{
return 'Requests';
}
public function tables(): array
{
return ['leads', 'lead_blocks', 'lead_taps'];
}
public function permissions(): array
{
return [
new Permission('leads.view', 'See the requests that came in', 'Requests'),
new Permission('leads.handle', 'Handle requests: mark as handled, add notes', 'Requests', needs: ['leads.view']),
new Permission('leads.manage', 'See what the screening kept away, move requests and block senders', 'Requests', needs: ['leads.handle']),
new Permission('leads.delete', 'Delete requests', 'Requests', needs: ['leads.view']),
];
}
public function navigation(): array
{
return [['label' => 'Requests', 'section' => 'Visitors', 'route' => Names::route('leads.index'), 'permission' => 'leads.view', 'simple' => true, 'hint' => 'The messages and requests from your website']];
}
/** @return array<string, array<string, mixed>> what the settings screen can change */
public function settings(): array
{
return [
'manager.leads.notify' => ['label' => 'Mail new requests to', 'type' => 'text', 'group' => 'Requests', 'sensitive' => true, 'help' => 'The mail address that is told about every real request', 'env' => 'MANAGER_LEADS_NOTIFY'],
'manager.leads.confirm' => ['label' => 'Mail the visitor a confirmation', 'type' => 'toggle', 'group' => 'Requests'],
'manager.leads.keep_days' => ['label' => 'Days a request is kept', 'type' => 'number', 'group' => 'Requests'],
'manager.leads.keep_spam_days' => ['label' => 'Days spam is kept', 'type' => 'number', 'group' => 'Requests'],
];
}
public function boot(): void
{
// A form may be sent so many times an hour per address, and by everyone together. Over the limit the visitor is told to wait.
RateLimiter::for('manager-leads', fn (Request $request) => [
Limit::perHour(max(1, (int) config('manager.leads.form.per_hour', 6)))->by('lead|'.$request->ip()),
Limit::perHour(max(1, (int) config('manager.leads.form.per_hour_all', 120)))->by('lead-all'),
]);
RateLimiter::for('manager-leads-token', fn (Request $request) => Limit::perMinute(60)->by((string) $request->ip()));
}
public function commands(): array
{
return [LeadsPruneCommand::class];
}
public function actions(): array
{
return [
'leads.handled' => ['Marked a request as handled or open'],
'leads.note' => ['Added a note to a request'],
'leads.folder' => ['Moved a request to another folder'],
'leads.block' => ['Blocked a sender'],
'leads.unblock' => ['Lifted the block of a sender'],
'leads.destroy' => ['Deleted a request'],
];
}
public function views(): array
{
return ['leads.index' => 'Opened the requests', 'leads.opened' => 'Opened a request'];
}
}
@@ -0,0 +1,74 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use IriksIT\Manager\Support\Names;
use IriksIT\Manager\Support\Tables;
return new class extends Migration
{
public function up(): void
{
// A request of a visitor: a callback request, a question or a quote request (the kinds are the site's to name).
Tables::create(Names::table('leads'), function (Blueprint $table) {
$table->id();
$table->string('kind', 20)->index();
// inbox (a real request), other (acquisition, something else) or spam. Set by the screening.
$table->string('folder', 20)->default('inbox')->index();
// Why it is in that folder, for who looks after the screening.
$table->json('reasons')->nullable();
$table->string('name');
$table->string('phone', 40)->nullable();
$table->string('email')->nullable();
// How the visitor wants to be reached: phone, whatsapp or email.
$table->string('prefers', 20)->nullable();
// What the visitor ticked: a job, or something else.
$table->string('about', 20)->default('job');
$table->text('message')->nullable();
// To see that the same text was sent before.
$table->string('message_hash', 64)->nullable()->index();
// What was tapped in the steps of a form, and when a callback suits.
$table->json('answers')->nullable();
$table->string('location', 120)->nullable();
// What the request is about, as the site names it (a service, a product): a label and the id it points to.
$table->string('subject', 255)->nullable();
$table->unsignedBigInteger('subject_id')->nullable();
// The page the form was on, and where the visit came from.
$table->string('page', 300)->nullable();
$table->string('channel', 20)->nullable();
$table->string('source', 80)->nullable();
// The address it was sent from, to be able to block a sender. Goes with the request.
$table->string('ip', 45)->nullable();
$table->dateTime('opened_at')->nullable();
$table->dateTime('handled_at')->nullable();
// won or lost, when that was said.
$table->string('outcome', 20)->nullable();
// Notes of the owner: a list of {at, by, text}.
$table->json('notes')->nullable();
$table->dateTime('notified_at')->nullable();
$table->boolean('notify_failed')->default(false);
$table->timestamps();
});
// A sender that is kept out: what they send goes to the spam folder.
Tables::create(Names::table('lead_blocks'), function (Blueprint $table) {
$table->id();
// email, domain, phone or ip.
$table->string('type', 20);
$table->string('value');
$table->string('reason')->nullable();
$table->dateTime('expires_at')->nullable();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('user_name')->nullable();
$table->timestamps();
$table->unique(['type', 'value']);
});
}
public function down(): void
{
Schema::dropIfExists(Names::table('lead_blocks'));
Schema::dropIfExists(Names::table('leads'));
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use IriksIT\Manager\Support\Names;
use IriksIT\Manager\Support\Tables;
return new class extends Migration
{
public function up(): void
{
Tables::create(Names::table('lead_taps'), function (Blueprint $table) {
$table->id();
$table->string('day', 10);
// call or whatsapp.
$table->string('kind', 20);
$table->string('path', 255);
$table->unsignedInteger('taps')->default(0);
$table->unique(['day', 'kind', 'path']);
});
}
public function down(): void
{
Schema::dropIfExists(Names::table('lead_taps'));
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use IriksIT\Manager\Support\Names;
use IriksIT\Manager\Support\Tables;
/**
* For a site that already has a table of requests (`manager.tables`): adds what the package wants to know about what a
* request is about. A table that has `service_id` (the old way: one kind of work) gives that id to `subject_id`; the old
* column stays, the site drops it when its own code no longer reads it. On a table the package made itself this does nothing.
*/
return new class extends Migration
{
public function up(): void
{
$table = Names::table('leads');
if (! Schema::hasTable($table)) {
return;
}
$hadSubjectId = Schema::hasColumn($table, 'subject_id');
Tables::addColumn($table, 'subject', fn (Blueprint $blueprint) => $blueprint->string('subject', 255)->nullable());
Tables::addColumn($table, 'subject_id', fn (Blueprint $blueprint) => $blueprint->unsignedBigInteger('subject_id')->nullable());
if (! $hadSubjectId && Schema::hasColumn($table, 'service_id')) {
DB::table($table)->whereNotNull('service_id')->update(['subject_id' => DB::raw('service_id')]);
}
}
public function down(): void
{
// The columns may have been there before the package: nothing to take away.
}
};
+13
View File
@@ -0,0 +1,13 @@
<?php
use Illuminate\Support\Facades\Route;
use IriksIT\Manager\Modules\Leads\LeadFormController;
use IriksIT\Manager\Support\Names;
// The forms of the public site. No session needed, nothing of the manager: `POST /{path}/{form}` takes a request in, `GET /{path}/token` gives a
// signed moment for a form that is built by script (a form in a page can use `Intake::formToken()`).
$path = trim((string) config('manager.leads.form.path', 'requests'), '/');
Route::get($path.'/token', [LeadFormController::class, 'token'])->middleware('throttle:manager-leads-token')->name(Names::route('leads.token'));
Route::post($path.'/tap', [LeadFormController::class, 'tap'])->middleware('throttle:manager-leads-token')->name(Names::route('leads.tap'));
Route::post($path.'/{form}', [LeadFormController::class, 'store'])->where('form', '[a-z0-9_-]+')->middleware(['web', 'throttle:manager-leads'])->name(Names::route('leads.store'));
+15
View File
@@ -0,0 +1,15 @@
<?php
use Illuminate\Support\Facades\Route;
use IriksIT\Manager\Modules\Leads\LeadsController;
Route::prefix('/leads')->where(['lead' => '[0-9]+', 'block' => '[0-9]+'])->group(function () {
Route::get('/', [LeadsController::class, 'index'])->name('leads.index')->middleware('can:leads.view');
Route::post('/{lead}/opened', [LeadsController::class, 'opened'])->name('leads.opened')->middleware('can:leads.view');
Route::put('/{lead}/handled', [LeadsController::class, 'handled'])->name('leads.handled')->middleware('can:leads.handle');
Route::post('/{lead}/notes', [LeadsController::class, 'note'])->name('leads.note')->middleware('can:leads.handle');
Route::put('/{lead}/folder', [LeadsController::class, 'folder'])->name('leads.folder')->middleware('can:leads.manage');
Route::post('/{lead}/block', [LeadsController::class, 'block'])->name('leads.block')->middleware('can:leads.manage');
Route::delete('/blocks/{block}', [LeadsController::class, 'unblock'])->name('leads.unblock')->middleware('can:leads.manage');
Route::delete('/{lead}', [LeadsController::class, 'destroy'])->name('leads.destroy')->middleware('can:leads.delete');
});