Obala
Obala
Explore posts from servers
FFilament
Created by Obala on 12/5/2024 in #❓┊help
How to pass an argument to a custom table actions
and thank you, you got me somewhere, the main issue was of passing the argument to the function used to generate the qr code, now that i can write the function inside the action its self pretty much solves my problem
11 replies
FFilament
Created by Obala on 12/5/2024 in #❓┊help
How to pass an argument to a custom table actions
this is how i wrote it initially
public function generateAndDownloadQRCodes(): \Symfony\Component\HttpFoundation\StreamedResponse
{
$events = CardTicket::all(); // Replace with your model
$tempDir = storage_path('app/qr_temp/');
$zipFilePath = storage_path('app/qr_codes.zip');

// Ensure temp directory exists
if (!file_exists($tempDir)) {
mkdir($tempDir, 0777, true);
}

// Generate QR codes for each event
foreach ($events as $event) {
$qrContent = json_encode([
'event_name' => $event->event_name,
'event_date' => $event->event_date,
'barcode' => $event->barcode,
]);

$fileName = $tempDir . Str::slug($event->event_name . '-' . $event->id) . '.png';

QrCode::format('png')
->size(300)
->generate($qrContent, $fileName);
}

// Create a ZIP file
$zip = new ZipArchive();
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
$files = glob($tempDir . '*.png');
foreach ($files as $file) {
$zip->addFile($file, basename($file));
}
$zip->close();
}

// Clean up temporary QR code files
array_map('unlink', glob($tempDir . '*.png'));
rmdir($tempDir);

// Return ZIP file as a download response
return response()->streamDownload(function () use ($zipFilePath) {
echo file_get_contents($zipFilePath);
}, 'qr_codes.zip', [
'Content-Type' => 'application/zip',
]);
}
public function generateAndDownloadQRCodes(): \Symfony\Component\HttpFoundation\StreamedResponse
{
$events = CardTicket::all(); // Replace with your model
$tempDir = storage_path('app/qr_temp/');
$zipFilePath = storage_path('app/qr_codes.zip');

// Ensure temp directory exists
if (!file_exists($tempDir)) {
mkdir($tempDir, 0777, true);
}

// Generate QR codes for each event
foreach ($events as $event) {
$qrContent = json_encode([
'event_name' => $event->event_name,
'event_date' => $event->event_date,
'barcode' => $event->barcode,
]);

$fileName = $tempDir . Str::slug($event->event_name . '-' . $event->id) . '.png';

QrCode::format('png')
->size(300)
->generate($qrContent, $fileName);
}

// Create a ZIP file
$zip = new ZipArchive();
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
$files = glob($tempDir . '*.png');
foreach ($files as $file) {
$zip->addFile($file, basename($file));
}
$zip->close();
}

// Clean up temporary QR code files
array_map('unlink', glob($tempDir . '*.png'));
rmdir($tempDir);

// Return ZIP file as a download response
return response()->streamDownload(function () use ($zipFilePath) {
echo file_get_contents($zipFilePath);
}, 'qr_codes.zip', [
'Content-Type' => 'application/zip',
]);
}
11 replies
FFilament
Created by Obala on 12/5/2024 in #❓┊help
How to pass an argument to a custom table actions
the action is on single row of items in the table, meaning that like and edit link on the table to links to a particular resource, the action also generates tickets for a single event
11 replies
FFilament
Created by Obala on 12/5/2024 in #❓┊help
How to pass an argument to a custom table actions
I want to allow users to generate QR codes for all tickets related to a specific event directly from the EventResource index page. The QR codes will: Be unique to each ticket. Be saved as images in storage. Be bundled into a downloadable ZIP file for the user. The action button will: Trigger the generation of QR codes. Handle the association with the event automatically via the passed id.
11 replies
TLCTuto's Laravel Corner
Created by Obala on 9/3/2024 in #💡filament
Multiple sub domain session sharing
it's was just browser cache
4 replies
FFilament
Created by Obala on 9/3/2024 in #❓┊help
Multi sub domain session sharing
I think I had issues with the browser caching, cos it's working perfectly fine on another browser
5 replies
FFilament
Created by Obala on 9/3/2024 in #❓┊help
Multi sub domain session sharing
let me look it through, thanks
5 replies
TLCTuto's Laravel Corner
Created by Obala on 2/9/2024 in #🚀laravel
Error in running npm install in wsl2
this works, thanks
10 replies
TLCTuto's Laravel Corner
Created by Obala on 2/9/2024 in #🚀laravel
Error in running npm install in wsl2
alright, let me try it out
10 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
Deleted all the default files and installed fresh installation of Laravel 10, added all the custom codes run composer install and every started working perfectly fine
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
this happens when i run php artisan route:cache
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
there's this issue with the api routes
Unable to prepare route [password/email] for serialization. Another route has already been assigned name [password.email].

at D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:247
243▕ $route->name($this->generateRouteName());
244▕
245▕ $this->add($route);
246▕ } elseif (! is_null($symfonyRoutes->get($name))) {
➜ 247▕ throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
248▕ }
249▕
250▕ $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute());
251▕

1 D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:208
Illuminate\Routing\AbstractRouteCollection::addToSymfonyRoutesCollection(Object(Symfony\Component\Routing\RouteCollection), Object(Illuminate\Routing\Route))

2 D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:246
Illuminate\Routing\AbstractRouteCollection::toSymfonyRouteCollection()
Unable to prepare route [password/email] for serialization. Another route has already been assigned name [password.email].

at D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:247
243▕ $route->name($this->generateRouteName());
244▕
245▕ $this->add($route);
246▕ } elseif (! is_null($symfonyRoutes->get($name))) {
➜ 247▕ throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
248▕ }
249▕
250▕ $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute());
251▕

1 D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:208
Illuminate\Routing\AbstractRouteCollection::addToSymfonyRoutesCollection(Object(Symfony\Component\Routing\RouteCollection), Object(Illuminate\Routing\Route))

2 D:\ivan\chcc-update\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php:246
Illuminate\Routing\AbstractRouteCollection::toSymfonyRouteCollection()
i don't if its the cause of this mess
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
usercontroller\
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
class CheckUserStatus
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);

if (Auth::check() && ! $request->user()->status) {
Auth::logout();
Flash::error('Your Account is currently disabled, please contact to administrator.');

return redirect()->back();
}

return $response;
}
}
class CheckUserStatus
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);

if (Auth::check() && ! $request->user()->status) {
Auth::logout();
Flash::error('Your Account is currently disabled, please contact to administrator.');

return redirect()->back();
}

return $response;
}
}
CheckuserStatus middleware
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
thats the app\http\kernel.php
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
Let me do so in a minute
15 replies
TLCTuto's Laravel Corner
Created by Obala on 9/14/2023 in #💡filament
how to set a value of an input field using values in a repeater
I have another though in Laravel , hope you can take a look at it, on middleware
12 replies
TLCTuto's Laravel Corner
Created by Obala on 9/14/2023 in #💡filament
how to set a value of an input field using values in a repeater
Oh yah totally forgot
12 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
yes, they are all setup and working, i only get the error say when i visit /profile without logging in first, butt when i visit route like /login or /register or the front routes which does not require authentication i don't get any error
15 replies
TLCTuto's Laravel Corner
Created by Obala on 10/3/2023 in #🚀laravel
my routes protected by auth middleware don't redirect to login page
here is my route and the middleware used
Route::middleware(['auth', 'verified', 'xss', 'checkUserStatus'])->group(function () {
Route::get('profile', [UserController::class, 'editProfile']);
Route::post('change-password', [UserController::class, 'changePassword']);
Route::post('profile-update', [UserController::class, 'profileUpdate']);
Route::post('update-language', [UserController::class, 'updateLanguage']);
});
Route::middleware(['auth', 'verified', 'xss', 'checkUserStatus'])->group(function () {
Route::get('profile', [UserController::class, 'editProfile']);
Route::post('change-password', [UserController::class, 'changePassword']);
Route::post('profile-update', [UserController::class, 'profileUpdate']);
Route::post('update-language', [UserController::class, 'updateLanguage']);
});
15 replies