Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

3d ago

I think you missed this part to adding your form element

Your form is missing enctype="multipart/form-data"
<form method="POST" action="{{ route('store') }}" enctype="multipart/form-data">
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1w ago

Sorry, I was kind a little bit in hurry to finish it somehow at that time. So, I missed it to implement it.

According to your advice. I will implement it on Saturday, as today I am working on some other cases.

Thanks, for your valuable time and advice.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

1w ago

@shivamyadav I see you didn’t take my advice (that I’m sure I mentioned a couple of times when you’ve posted about this Google Drive-related project) of moving your Google Client creation logic to a service provider, so that classes then using that client (controllers, etc) just need to type-hint it and it will be automatically built and resolved:

public function register(): void
{
    $this->app->singleton(Client::class, function (Application $app) {
        return new Client([
            'client_id' => $app['config']['services.google.client_id'],
            'client_secret' => $app['config']['services.google.client_secret'],
            'scopes' => 'https://www.googleapis.com/auth/drive',
            'redirect_uri' => $app['config']['services.google.redirect_uri'],
            'prompt' => 'consent',
            'access_type' => 'offline',
        ]);
    });
}

For refreshing access tokens, I have a scheduled task that fires daily to refresh any soon-to-expire access tokens. But again, I’m sure I’ve mentioned this before:

Schedule::command('access-token:refresh')->daily();

If you find you’re unable to refresh an access token (because it’s been revoked by the owner), then you can delete it, and send a notification to the owner telling them they need to re-connect their Google account.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1w ago

Thanks for the reply ☺️.

Actually this was the issue it was silently truncating the data and it get's only stored a allowed bytes of charcters to the table.

Yeah, I have already fixed and moved the constructor logic out and created a method authenticate and using it simply

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

1w ago

Your logic is actually fine. The problem is almost certainly your database migration.

Google access tokens are frequently longer than 255 characters. If you used $table->string('access_token') in your migration, Laravel defaults to a VARCHAR(255) and is silently truncating your token when saving it to the database.

Here is exactly why your test behaved that way: When you omit the created key, the Google client assumes the token is expired and forces a refresh. It then uses the full, fresh token directly from memory, which is why it works. However, when you include created, the client checks the timestamp, sees it hasn't been an hour yet, and sends the truncated (corrupted) token from the database to Google. Google rejects it, triggering the 401 Unauthorized.

Change your columns to text in your database migration:

$table->text('access_token');
$table->text('refresh_token');

Clear out your oauth_credentials table and re-authenticate to store a fresh, full-length token.

Avoid putting heavy external API calls inside a __construct(). If Google's API goes down, times out, or rate-limits you, your entire class fails to instantiate and it can crash Laravel's service container resolution. Move the token initialization to a dedicated connect() or boot() method that you call when you actually need to interact with the Drive API.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

3w ago

Not started just asked S better version of my question to get better help from people 🙏😔

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

3w ago

Yeah, from gpt.

I told him that this is what I was thinking is there any security vulnerabilities that can occurs and write a thread post to get the feedback from the professional and senior to the it field.

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

3w ago

I’m building a lightweight Laravel-based attendance system where users can check in/out only when they are physically present within a strict 10–20 meter radius of the workplace using live GPS validation.

  1. ⚙️ Core Features Implemented 2.📍 Real-time geofencing (strict 10–20m radius enforcement)
  2. 🎯 GPS accuracy filtering (reject low-accuracy readings)
  3. ⏱️ Live check-in only (no delayed or backdated submissions)
  4. 🚫 Mock location detection (Android-based checks)
  5. 📱 Device tracking (basic fingerprinting for consistency)
  6. 🤳 Selfie Verification Approach (No AI)

To keep the system lightweight and privacy-friendly, I’m intentionally avoiding AI/ML solutions.

Current approach:

  1. Capture a selfie during check-in
  2. Compare it with a previously stored reference image
  3. Use pixel-level comparison techniques, such as:
    1. Image difference
    2. Hashing (e.g., perceptual hash)
    3. Similarity scoring

❓ Feedback I’m Looking For

I’d really appreciate insights from experienced developers on the following:

  1. Reliability How reliable is pixel-based image comparison in real-world usage?
  2. Real-world Variations How should I handle: 1. lighting differences 2. face angle changes 3. different camera quality
  3. Alternatives (Without AI) Are there any better non-AI approaches for basic face verification?
  4. Feasibility Is this approach fundamentally flawed for identity verification?
  5. Improvements Would capturing multiple selfies (2–3 per check-in) improve accuracy or just add noise? 🎯 Goal

The aim is to build a system that is:

  1. ✅ Simple to integrate
  2. ⚡ Lightweight (no heavy dependencies)
  3. 🔒 Privacy-friendly (no AI processing)
  4. 🛡️ Reasonably resistant to misuse

🙏 Closing

Any suggestions, critiques, or alternative approaches would be greatly appreciated. Looking forward to learning from your experience!

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1mo ago

Try this as the route ziggy package does not provide the reactive data on page navigation. You need to use the vue's reactivity with the route of the ziggy like this :

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

1mo ago

I have a GoogleDriveService to mange the work for the drive related.

Earlier it was setup by me to work like get the new refresh access token for each request and it was working fine.

Yesterday my senior suggested me to use this way: 1. To add the logic only get the new access token if it is expired. 2. I have added this logic but now I am getting 401 (Unauthorized) error.

My constructor code

As soon i removed this below line form the top (first) set access token 'created' => (int) $accessToken['token_created_at'], // Unix timestamp It works but now each time it fetches the new access token for it.

Main error i am getting

"error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "errors": [
      {
        "message": "Invalid Credentials",
        "domain": "global",
        "reason": "authError",
        "location": "Authorization",
        "locationType": "header"
      }
    ],
    "status": "UNAUTHENTICATED"
  }
}
Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

1mo ago

For the first time when I click to my sidebar notifications button it does two things:

  1. Navigate to the notifications page.
  2. Clears the notification badges for the new emails.

And then I tried some filter to the notifications and when I am done with the filtering and click on the notifications button again it works again for step 1 and step 2 but the issue arrives here in the form of the not letting the search and other inputs gets cleared but the data is at the initial state without applied any filter and url is also clean.

I have tried with the preserveState to be false for the below function markNewMailsRead() but did not worked.

Is there something I am missing or any solution for this issue.

My sidebar link component

<SidebarLink @click="markNewMailsRead" :href="route('notifications.index')"
                    :active="isActiveLink('notifications.index')">
                    <div class="flex items-center justify-between w-full">
                        <!-- Left -->
                        <div class="flex items-center gap-4">
                            <Bell class="size-5" />
                            <span>Notifications</span>
                        </div>

                        <!-- Badge -->
                        <div v-if="totalNewMails" class="relative">
                            <!-- Pulse ring -->
                            <span class="absolute inset-0 rounded-full bg-primary animate-ping"></span>

                            <!-- Count -->
                            <span class="relative flex items-center justify-center
                                w-6 h-6 p-1
                                rounded-full bg-primary
                                text-xs font-bold text-black">
                                {{ totalNewMails > 99 ? '99+' : totalNewMails }}
                            </span>
                        </div>
                    </div>
</SidebarLink>
// INFO: New Mail mark as read ( to just make the live new count 0)
const markNewMailsRead = () => {
    router.post(route('notifications.new-mails.read'), {}, {
        preserveScroll: true,
        preserveState: true,
    });
};
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1mo ago

Thanks for the info. I did not know about the env direct helper issue in the code.

I have already setup the oauth and using and it works fine now.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

1mo ago

@shivamyadav As @ian_h says, you should not be using the env helper in your code. The Laravel docs also tell you not to do this.

Instead, you should be binding that class in the service container where the configuration values are passed to your constructor:

public function register(): void
{
    $this->app->singleton(GoogleDriveService::class, function () {
        return new GoogleDriveService(
            clientId: $this->app['config']['services.google.drive.client_id'],
            clientSecret: $this->app['config']['services.google.drive.client_secret'],
            redirectUri: $this->app['config']['services.google.drive.redirect'],
        );
    });
}

You can then just type-hint the service class, and it will be resolved (and configured) by the service container:

class SomeController extends Controller
{
    protected GoogleDriveService $googleDrive;

    public function __construct(GoogleDriveService $googleDrive)
    {
        $this->googleDrive = $googleDrive;
    }
}

As for the error, it’s telling you what the problem is: service accounts don’t have a storage quote, so you can’t use service accounts for storage-related operations like you’re trying to do. You need to use an OAuth approach so you’re authenticating as a user, who will have a storage quota. You can use Socialite to create (and refresh) Google access tokens.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1mo ago

With the doc and little bit help of ai.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

1mo ago

Also, I'd highly recommend not using env() in the code, rather Config::get() as the former will cause you issues when you cache the config in production.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

1mo ago

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

1mo ago

Currently I am using the service account and setup the testing route with the credentials and getting this error:

Route::get('/drive-test', function () {

    $service = new \App\Services\GoogleDriveService();

    $fileId = $service->upload(
        storage_path('1770402265.shivam-resume (1).pdf'),
        'test.pdf'
    );

    return $service->getFileUrl($fileId);
});
Google \ Service \ Exception (403)
{ "error": { "code": 403, "message": "Service Accounts do not have storage quota. Leverage shared drives (https://developers.google.com/workspace/drive/api/guides/about-shareddrives), or use OAuth delegation (http://support.google.com/a/answer/7281227) instead.", "errors": [ { "message": "Service Accounts do not have storage quota. Leverage shared drives (https://developers.google.com/workspace/drive/api/guides/about-shareddrives), or use OAuth delegation (http://support.google.com/a/answer/7281227) instead.", "domain": "usageLimits", "reason": "storageQuotaExceeded" } ] } }
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

After reading your reply. I thought yeah this is the way I can achieve it.

Also I can check the every pagination data listing with that source of truth and mark the checkbox for every visiting page to checked the box to provide the feedback to the user and got the some help from the AI to unselected paginations data listing could be added to the another source of truth like. excluded_records which will hold the ID's which does not required to be deleted.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

Since not all the records are loaded - there's no way to know which records to select, you'd need to send a key in order to remove all, for example, selected_all=true

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

2mos ago

I have created a notification listing with the pagination but I want to delete all the notifications or only the selected one to delete it.

  1. I was using the checkbox for each record and the top header select all the records form the listing and it selects all the records but only from which ever page I select the header checkbox to select all the listing.
  2. When I go to the 2nd page it's record listings was not selected how to get the all the listing selected within the pagination too?
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Thanks snapey. This weekend I will try it to upgrade it with Laravel 12.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

That's effectively the best way.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

Start a Laravel 12 project and replicate all the functionality. Don't even try to do a step by step upgrade.

You will face far fewer problems this way, plus you will actually understand the project.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

If you were in my place what's was your approach to migrate the older project to at least Laravel 8

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

Laravel 4.1 is ancient and I wouldn't try to migrate it step by step.

  • The intermediate versions won't work with modern PHP versions. Laravel 4 doesn't support PHP 7+.
  • The intermediate versions will require obsolete or completely removed extensions, as you found out with Mcrypt.
  • You'll have to rewrite parts of the app completely along the way. Laravel 4 doesn't even have middleware. It used filters instead, which were removed in L5.

If I were you, I'd create a fresh Laravel 12 project with PHP 8.x, and start moving the business logic from the old app to the new one, piece by piece.

You'll still have to read every upgrade guide along the way, especially the major version ones.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

Why only migrate to 4.2 ? This could be done by following the upgrade guide.

But I suggest you to migrate to Laravel 12.

For such a migration, I suggest you to create a new Laravel application and copy / paste the code from your old application to your new one. Then you will have to change some code to be compatible with the recent PHP versions and with the new structure for the application folder.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

I will try it ☺️

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Yeah but I need to make sure I follow every steps properly if by mistake I missed any of them then I think I will have to face major issues.

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

2mos ago

Currently I have assigned a project to migrate it. As this is the first time I am working on the migrating the older project.

Current Working state:

  1. I have installed a new fresh laravel 4.2 project and according to the upgrade guide I have makes the necessary changes and put the copied existing older project with laravel version 4.1.
  2. New fresh project is using the php 7.3 and mysql 9.
  3. I have copied the the older project composer.json to the new project but kept the laravel version to the 4.2 and other things.
  4. Now when I ran any artisan command I get this error Mcrypt PHP extension required.

How to fix it. I have tried to resolve it from the AI too but It seems not working.

Any help would be appreciated.

Shivamyadav's avatar

Shivamyadav was awarded Best Answer+1000 XP

2mos ago

Here is the key thing...

// Searched on Google and got this load missing() used case.

Laravel's loadMissing() method is used to eager load a relationship on a model or a collection of models only if that relationship has not already been loaded.

  1. withPivot() only applies when the relationship is loaded for the first time.

  2. If groups.articles was already loaded earlier without the formula column, loadMissing() will not re-query or add new pivot fields.

  3. Eloquent treats the relationship as already loaded, so this behavior fails silently by design.

I think you can define the 2 relationship one for without formula and other with formula

Like this ..

//Without formula relationship 
public function articles(): BelongsToMany
{
    return $this->belongsToMany(Article::class, 'group_article')
        ->using(GroupArticle::class)
        ->withPivot('rounding_rule', 'precision');
}

// With formula needed 
public function articlesWithFormula(): BelongsToMany
{
    return $this->belongsToMany(Article::class, 'group_article')
        ->using(GroupArticle::class)
        ->withPivot('formula', 'rounding_rule', 'precision');
}
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Here is the key thing...

// Searched on Google and got this load missing() used case.

Laravel's loadMissing() method is used to eager load a relationship on a model or a collection of models only if that relationship has not already been loaded.

  1. withPivot() only applies when the relationship is loaded for the first time.

  2. If groups.articles was already loaded earlier without the formula column, loadMissing() will not re-query or add new pivot fields.

  3. Eloquent treats the relationship as already loaded, so this behavior fails silently by design.

I think you can define the 2 relationship one for without formula and other with formula

Like this ..

//Without formula relationship 
public function articles(): BelongsToMany
{
    return $this->belongsToMany(Article::class, 'group_article')
        ->using(GroupArticle::class)
        ->withPivot('rounding_rule', 'precision');
}

// With formula needed 
public function articlesWithFormula(): BelongsToMany
{
    return $this->belongsToMany(Article::class, 'group_article')
        ->using(GroupArticle::class)
        ->withPivot('formula', 'rounding_rule', 'precision');
}
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

My sidebar navigation button. Notificationss tab on which I am already

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

2mos ago

In my projects / Index component i have this code and when I search anything and get's the expected result and try to navigate back to the same projects/ index url on i had searched earlier the input search component get's clear and even also from the url params.

my code

The main issue comes here in the Notifications / Index component I was expecting the same behaviour but did not get the input cleared.

  1. The url search query gets removed but the input search has the searched value.
  2. Event using the smae approach for the both components.

my code

Is there anything I am missing ?

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Ohh man 😜

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Show me your migration file for the profile table.

There must be wrong foreign key name. I am pretty sure it will be not named as user_id

Shivamyadav's avatar

Shivamyadav was awarded Best Answer+1000 XP

2mos ago

Laravel expects helpers to be autoloaded, not dynamically declared.

Did you added the helper class to the composer.json Or you may forget to run the command

composer dump-autoload
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

What did you changed to solve the issue? 🧐

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Laravel expects helpers to be autoloaded, not dynamically declared.

Did you added the helper class to the composer.json Or you may forget to run the command

composer dump-autoload
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

If you really want to use the facade:

@php
    use Illuminate\Support\Facades\Session;
@endphp

@if ($message = Session::get('flash'))
    <div class="alert alert-success">
        {{ $message }}
    </div>
@endif 

Or just use the session helper function

@if (session('success'))
    <div class="alert alert-success">
        {{ session('success') }}
    </div>
@endif 
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

How to customise this table?

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

@shivamyadav That makes absolutely no difference. I use SQS myself. You don’t need to store failed jobs in a custom table just to then present them in a UI.

You can query the failed_jobs table just like any other table:

$failedJobs = DB::table('failed_jobs')->paginate();
@foreach($failedJobs as $failedJob)
    <tr>
        <td>{{ $failedJob->uuid }}</td>
        <td>
            <!-- Button to re-try failed job -->
        </td>
    </tr>
@endforeach
Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Any suggestions how to manage it?

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Where?

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

As we are using the AWS so, I don't know how the AWS SQS works but it also stored the failed jobs but something different way it Store the payload and unique I'd as like primary key not the job uuid.

Shivamyadav's avatar

Shivamyadav liked a comment+100 XP

2mos ago

Yes, I think he just was a list of all failed jobs in the ui listing

@shivamyadav Your senior is literally re-inventing the wheel.

You could have just used Horizon for Redis-based queues. If you’re not using Redis, you still don’t need to push jobs to an entirely new table. You could have just queried Laravel’s native failed_jobs table. I’ve done it myself; including with a button to re-try failed jobs; no custom table needed.

Given the questions you’ve asked in such a short span of time, I don’t feel this “senior” is really someone you want to be learning habits from, as they seem to be senior in name only.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Yes, I think he just was a list of all failed jobs in the ui listing and from there it self he could have an option to trigger all failed jobs or a particular without using the terminal. Everytime we don't have system with us may be for that thing.

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

My senior asked me to Store each job to the custom table with it's status queued, processing, processed or failed and later we can manually retry the failed jobs from the custom table with the payload.

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

2mos ago

My app service provider queue event store the failed jobs to the custom table

Queue::failing(function (JobFailed $event)  use ($queueJobStatusRepository) {
            /** Extracting the current job class name */
            $job = $event->job;
            $payload = $job->payload();
            $action = $payload['displayName'];
            /** Extracting the current job class name */

            $queueJobStatusRepository->updateOrCreate(
                ['job_id' => $event->job->uuid()], // INFO: Uniquely identify to create or update
                [
                    'action' => $action, // INFO: Get the current Event / Job Class name
                    'status' => 4, // INFO: Failed
                    'exception' => str()->limit($event->exception->getMessage(), 2000)
                ]
            );
        });

I want to get the failed job uuid and based on that I could push that failed jobs to the queue again to process it.

Shivamyadav's avatar

Shivamyadav started a new conversation+100 XP

2mos ago

My senior uses the repository patterns to work with the controller business logics. In the function he has the create and update method to create/ update the resource and other side effects to perform actions whenever resource gets created or updated and both were approximately 900 of lines.

That was really too hard to understand it and overwhelming for me to just looking at the no of the lines in the function.

How long no of lines any function could have?

Shivamyadav's avatar

Shivamyadav wrote a reply+100 XP

2mos ago

Sorry 😔.

I will provide the information once I am on my machine.

For now my senior has written the whole code and and was optimising it and find that the creation of the user was the problem with many things like creating user stripe account and divisions, experts etc.

So I just put that in a queue and imported the user's again and now it's taking 8 minutes.

Without the job (as if I commented the job) it was taking one 1.20 min and added the job it's taking that 8 minutes like resolving the jobs dependency and serealizing the constructor payload and I am using the AWS SQS.