Files
hoshpoint-backend/app/Http/Controllers/Admin/GenerationDownloadController.php
soheil khaledabadi 936f789ac8 feat: Persian panel/API fixes and structural-model tweaks
- lang/fa: add validation/auth/passwords/pagination translations so admin
  and API validation errors are in Persian
- templates: soft-delete instead of cascade-deleting their generations;
  keep resolving trashed template on generations (labels/downloads)
- templates: add TemplateInfolist with a real thumbnail ImageEntry
- generations: auto-name template-based generations and use that name
  for the download file and as a searchable column
- admin: show all dates as Jalali via ->jalaliDate()/->jalaliDateTime()
  Filament macros (App\Support\Jalali)
- wallets: harden the deposit/withdraw action to surface the exact error
  instead of a 500
- profile: normalize Iranian mobile numbers (App\Support\Mobile),
  add social_links, coerce notification-preference booleans, require the
  current password to delete an account

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013P66ea1dC5CVM9t29496t5
2026-09-07 01:00:09 +03:30

24 lines
823 B
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Enums\TemplateGenerationStatus;
use App\Http\Controllers\Controller;
use App\Models\TemplateGeneration;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;
class GenerationDownloadController extends Controller
{
public function __invoke(Request $request, TemplateGeneration $generation): StreamedResponse
{
$user = $request->user();
abort_unless($user && ($user->hasRole('admin') || $user->hasPermission('templates.manage')), 403);
abort_if($generation->status !== TemplateGenerationStatus::Completed || ! $generation->output_path, 404);
return Storage::disk('local')->download($generation->output_path, $generation->downloadFilename().'.pptx');
}
}