Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9

Is this a how to use maatwebsite/excel article?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

verify mail

This happens because the starter kits (Breeze/Jetstream) wrap that verification route in the auth middleware by default. When you open the link in a different browser, you're a "guest," so the middleware intercepts the request and redirects you to the login page before the verification logic even runs.

To fix this, you need to allow guests to hit that endpoint and manually find the user since $request->user() won't be available.

First, in routes/auth.php, move the route outside the auth middleware group, Then, you'll need to tweak the VerifyEmailController. Since you aren't using the auth middleware anymore,

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Can't browse site after clonning git repository

You're mixing yarn and npm, which seems weird to me. Use npm run dev instead of yarn dev.

The bundler is complaining about not finding resources/admin/sass/admin.scss. Does it exist?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Can't browse site after clonning git repository

Hello,

Using Laravel 12, I cloned my github repository into c:\wamp64\www

I ran: composer install

composer update

npm install

I copied my .env file from a previous folder I had for this project.

I ran yarn dev, got these errors:

(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: failed to resolve rollupOptions.input value: "resources/admin/sass/admin.scss". at resolvePath (file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:31449:29) at async Promise.all (index 2) at async computeEntries (file:///C:/wamp64/www/mysite.local/node_modules/vite at async scan (file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:31388:19) at async file:///C:/wamp64/www/mysite.local/node_modules/vite/dist/node/chunks/config.js:34131:15

I have the right database credentials and the actual database.

Trying to run the site in the browser, I get this message:

Looks like there’s a problem with this site

Firefox can’t connect to the server at mysite.local What can you do about it?

Try connecting on a different device. Check your modem or router. Disconnect and reconnect to Wi-Fi.

What am I doing wrong please?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

2d ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

verify mail

I think there was a video from Jeffrey about passwordless authentication

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9
  1. resources/views/products create.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

<div class="bg-white rounded shadow p-6">
    <form method="POST" action="{{ route('products.store') }}">
        @csrf

        {{-- Name --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
            <input type="text" name="name" value="{{ old('name') }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('name') border-red-400 @enderror">
            @error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
        </div>

        {{-- Category --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
            <input type="text" name="category" value="{{ old('category') }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">
        </div>

        {{-- Price & Quantity side by side --}}
        <div class="flex gap-4 mb-4">
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Price *</label>
                <input type="number" name="price" value="{{ old('price') }}" step="0.01" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('price') border-red-400 @enderror">
                @error('price') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Quantity *</label>
                <input type="number" name="quantity" value="{{ old('quantity', 0) }}" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('quantity') border-red-400 @enderror">
                @error('quantity') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
        </div>

        {{-- Description --}}
        <div class="mb-6">
            <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
            <textarea name="description" rows="3"
                      class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">{{ old('description') }}</textarea>
        </div>

        <div class="flex gap-3">
            <button type="submit"
                    class="bg-blue-600 text-white px-5 py-2 rounded hover:bg-blue-700 text-sm">
                Save Product
            </button>
            <a href="{{ route('products.index') }}"
               class="px-5 py-2 rounded border text-sm text-gray-600 hover:bg-gray-50">
                Cancel
            </a>
        </div>
    </form>
</div>

@endsection edit.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

<div class="bg-white rounded shadow p-6">
    <form method="POST" action="{{ route('products.update', $product) }}">
        @csrf @method('PUT')

        {{-- Name --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Name *</label>
            <input type="text" name="name" value="{{ old('name', $product->name) }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('name') border-red-400 @enderror">
            @error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
        </div>

        {{-- Category --}}
        <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
            <input type="text" name="category" value="{{ old('category', $product->category) }}"
                   class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">
        </div>

        {{-- Price & Quantity --}}
        <div class="flex gap-4 mb-4">
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Price *</label>
                <input type="number" name="price" value="{{ old('price', $product->price) }}" step="0.01" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('price') border-red-400 @enderror">
                @error('price') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
            <div class="flex-1">
                <label class="block text-sm font-medium text-gray-700 mb-1">Quantity *</label>
                <input type="number" name="quantity" value="{{ old('quantity', $product->quantity) }}" min="0"
                       class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400 @error('quantity') border-red-400 @enderror">
                @error('quantity') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>
        </div>

        {{-- Description --}}
        <div class="mb-6">
            <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
            <textarea name="description" rows="3"
                      class="w-full border rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-400">{{ old('description', $product->description) }}</textarea>
        </div>

        <div class="flex gap-3">
            <button type="submit"
                    class="bg-blue-600 text-white px-5 py-2 rounded hover:bg-blue-700 text-sm">
                Update Product
            </button>
            <a href="{{ route('products.index') }}"
               class="px-5 py-2 rounded border text-sm text-gray-600 hover:bg-gray-50">
                Cancel
            </a>
        </div>
    </form>
</div>

@endsection index.blade------------------------------------------------------------------------------------------------------------------- @extends('layouts.app')

@section('content')

{{-- Flash Messages --}} @if(session('success')) {{ session('success') }} @endif

{{-- Table --}}

{{-- Pagination --}}

@endsection

  1. resources/views dashboard------------------------------------------------------------------------------------------------------------------- {{ __('Dashboard') }}

reports.blade------------------------------------------------------------------------------------------------------------

@extends('layouts.app')

@section('content')

{{-- Summary Cards --}}

{{-- By Category --}}

{{-- Full Product List --}}

@endsection

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9
  1. Exports ProductReportExport ----------------------------------------------------------------------------------------
vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9
  1. maatwebsite/excel for Excel exports.

composer require maatwebsite/excel

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

  1. App/Models

Product ---------------------------------------------------

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9
  1. web.php------------------------------------------------------------------------------------------------------------------
vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

IT9

Question?

vincent15000's avatar

vincent15000 wrote a reply+100 XP

2d ago

IT9

Do we have to guess your question ?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Database Replication

@eskiesirius This is literally the definition of premature optimisation…

vincent15000's avatar

vincent15000 wrote a reply+100 XP

2d ago

I accidentally deleted a Controller. How to recover?

Perhaps he has generated the code with an AI ... sorry I just want to make a joke ;).

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

No, I do not use git at all.

@adamnet May I suggest you start doing so? And it will save you in situations like this.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

@shez1983 The term here is commit. You don't need to upload changes anywhere as long as you get in the habit of committing frequently.

@adamnet It looks like VSCode has this feature, sort of. Type CTRL/CMD + P, and find "Local history: Find Entry to Restore". You should find your file contents there. Unlike in PHPStorm, it doesn't look like you can straight up restore the file from history (the IDE gets confused because the file doesn't exist), but at least you can copy the contents and re-create it.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

but it sounds like h e was working on it and didnt get a chance to save/upload it - in which case git wouldnt have helped..

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

This would be a good time to start.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

Not sure how VS Code handles local history... any chance that you had committed the file to git?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

I use Visual Studio Code editor. There is an option there: Open the Command Palette by pressing Cmd+Shift+P Paste the phrase "Local History: Find Entry to Restore" . I could not find the file Thanks for answering.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

Was it ever commited in git?

Otherwise, if using PHPStorm, there is a Local History in File >> Local History >> Show History. Other editors/IDEs may have a similar feature?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

Delete migration file in project. Way to restore?

Earlier today I created a migration file for creating a table with a lot of columns, foreign keys etc. Accidentally I deleted it. Is there any way to restore it? Is there a recycle bin into the project?

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

I accidentally deleted a Controller. How to recover?

Oh, you're right: thread.

@jussimannisto I seldom forget things I’ve read or seen. It’s a blessing and a curse 😅

vincent15000's avatar

vincent15000 wrote a reply+100 XP

2d ago

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

I accidentally deleted a Controller. How to recover?

I accidentally stabbed myself in the foot. Is there any way to unstab my foot? I only have two feet and this one is used to kick the cat so I cant afford to lose it.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

2d ago

verify mail

What you want is not the normal behavior.

If you really want this, I suggest you to generate your own temporary email verification link and handle the verification by your own in a controller.

vincent15000's avatar

vincent15000 liked a comment+100 XP

2d ago

verify mail

In a new laravel site/ app with starter kit the registration is not what I expect. After registration, the user must register his email. So in My model I added MustVerifyMail. After registering, the https://{mysite}/verify-email page will be loaded. You can choose to log out or resend verification mail. The email comes in. but can only work in the open browser where you have not yet logged out. If you are logged out, the link will not work and you will go back to the login page. the email_verified_at is not entered in the database.

The routes auth.php contain the routes linked to the middleware auth.

Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)->middleware(['signed', 'throttle:6,1'])->name('verification.verify');

and

Route::get('verify-email', EmailVerificationPromptController::class)->name('verification.notice');

How can I make it so that verification is possible even if the user is already logged out or is using a different browser.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

3d ago

Event-Driven Architecture, do I need it?

Not sure that this comment is really the best answer ;).

vincent15000's avatar

vincent15000 wrote a reply+100 XP

4d ago

I'm having problems on deciding an architecture for sub navs, and I'm having trouble on deciding how to manage the page without refresh without messy code.

The only way to update the content of a page without refreshing the page is to use AJAX request, so you have to use JavaScript, send the requests from JS (for example with axios or the native JS function fetch) and update manually the DOM.

You can do this an easier way using either AlpineJS, or HTMX, or Turbo, or simply why not Livewire.

https://alpinejs.dev/

https://laravel.com/docs/13.x/blade#rendering-blade-fragments

https://laracasts.com/series/crafting-web-applications-with-htmx

https://htmx.fr/

https://turbo.hotwired.dev/

https://livewire.laravel.com/

If you want to keep your code light, I suggest you rather AlpineJS or HTMX or Turbo.

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

I'm having problems on deciding an architecture for sub navs, and I'm having trouble on deciding how to manage the page without refresh without messy code.

I'm creating a community based SN, I created manage section for community owners, and there is nav on top like general, privacy, sections (flairs), users (follow, requests), posts (requests, pinned, etc.) inside. I created blade pages for them, but inside them there are sections again. Like Followed, Requests, Pinned, Removed etc. Making separate pages for them would be bad. I don't know if I should just send arguments ?filter=request and display it based on that. What would be professional way for this type of sub sections (navs)?

Also after creating some things I just realized that I have to make sure the page is not getting refresh with the actions like follow, pin, remove, reject, accept etc. There are tons of them, I did follow, delete with the async fetching with js. And also realized I have to fetch posts with it too because of pagination. I don't want it to refresh for next other 20 posts every time. I'm wondering if it would be ok to use tons of async fetch and dom manipulation in the page.

I'm doing this with laravel and without front frameworks. I am having trouble on how to do the architecture so it won't bite me back. I would appreciate your suggestion and examples on these things.

Edit: also, which is the better way, using toggle on action like ban/unban, like/dislike, follow/un, pin/unpin, or creating separate routes and functions for them?

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

Observer and scheduled publish dates

You already hit the nail on the head observers only fire on database operations, and time passing isn't a database operation.

Like the others mentioned, a scheduled command running everyMinute(). Instead of adding a published_processed_at timestamp though, I usually just rely on a status column (e.g., switching it from scheduled to published). Grab records where published_at <= now() and status === 'scheduled', fire your service, and update the status.

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

Connect to postgres cluster

What are you trying to achieve by including it to begin with?

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

Connect to postgres cluster

When automatic failover swithces traffic from primary to replica I need connection in laravel to switch as well

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

Connect to postgres cluster

I was asking why you added that option. It's not in the database config file by default. Did you read what it does from the Postgres docs?

You've set target_session_attrs to read-write for all connections, which means you cannot connect to the hosts you defined under read if they're read-only connections.

You also have a separate host array at the root level in addition to read and write hosts. I don't know Laravel interprets this, but it might mess things up. I recommend you read the docs before continuing.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

4d ago

Observer and scheduled publish dates

Yes exactly what I said in the previous comment.

vincent15000's avatar

vincent15000 liked a comment+100 XP

4d ago

Observer and scheduled publish dates

You misunderstand what observer is. It has nothing to do with your task. You should schedule a command every N minutes (whatever frequency you prefer) which:

  • takes records ready to be published (in other words, which have published_at in less than N minutes in future)
  • publishes them
  • applies service function you want to be applied to "scheduled" records.

Model observers are about events system, this is another topic.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

how to listen globally to livewire updating hook from AppServiceProvider.php in livewire 4

thanks for answer i tried custom class before not working something like

        Livewire::componentHook(PropertySecurityHook::class);

i think the main point now global hook or listener for editing more then a month iam working in this package .. it's possible in livewire 3 global listener . but in liveiwre 4 did not working - i will trying search for more ideas . the main point realted to livewire v4

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

how to listen globally to livewire updating hook from AppServiceProvider.php in livewire 4

This

public function register()
{
    app('livewire')->componentHook(PropertySecurityHook::class);
}

I have been using custom class as component hook since L4 launch and it works as expected

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

how to listen globally to livewire updating hook from AppServiceProvider.php in livewire 4

ohh thanks so much now it's working my code was inside boot() did not working after i moved it to register() it's working now in both ways are working thanks so much now i can track the hook i will continues working on package thanks again

vincent15000's avatar

vincent15000 wrote a reply+100 XP

5d ago

Observer and scheduled publish dates

An observer will just listen to events. If you don't trigger any event, the observer doesn't do anything. Except for all CRUD actions (creating, created, updating, updated, ...) for which Laravel fires events automatically.

In your case, I think that you don't need any observer, but just a custom artisan command and execute it periodically via a cron task.

But I don't know exactly what you are trying to do, so it's difficult to give you the right answer without knowing more about the context.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

I just make an SSH script that dumps the DB, copies the env file, and tars the storage folder, then syncs everything to a remote server. Restoring is just the reverse.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

Well. I have my codebase as repository on Github. DB is supabase and storage is S3. And the server where i have Laravel forge installed has a daily backup.

N.B: The repository is private.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

I host all my own sites since I run a home datacenter so I have backups on the application storage, db & file storage on raspberry pi 5s with 2tb nand ssds, also off site backups to my dedicated server on ovh

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

@laracoft My code is a repository that’s on both my computer and GitHub; user-uploaded assets are stored in S3; and my applications are deployed to Heroku, which automatically creates a database back-up daily.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

Can anyone share how they are doing backups and restore of multiple Laravel projects?

In particular, I'm concerned with DB, .env and storage as these are not version controlled.

Preferably it is all done via SSH.

I'm hoping it is easy to setup, verify that it is working correctly and of course, easy to restore too.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

For DB, I just dump:

mysqldump -uzzzzzzz -pzzzzzzzz --add-drop-database --databases --routines tjtransactions > "D:\zipfold\mysql_backs\xbacks\tjtransactions.sql"

But I believe Spatie has a routine for this, check theit site, or I know github has packages for this also.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Backup and restore Laravel projects

I use spatie backup with the target as S3, on about 20 sites.

However, I probably restored less than a handful in 10 years.

vincent15000's avatar

vincent15000 wrote a reply+100 XP

5d ago

Implement ticket watch feature like jira,clickup using laravel

You don't need any package to do that.

Hmmm ... I wonder ... what's your experience in programming ?

As @tisuchi said, you just have to create a pivot table to know who is watching which ticket and then fire an event for each action done related to a ticket.

vincent15000's avatar

vincent15000 liked a comment+100 XP

5d ago

Implement ticket watch feature like jira,clickup using laravel

I’d add a watchers table with user_id and ticket_id, then a simple toggle method. On ticket updates, fire a notification to all watchers using Laravel’s notifications or queued mails.