Laravel testing database table is being accessed by other users

I’m currently building a multi-tenant application using stancl/tenancy (every tenant uses their own database) in my Laravel application.

Whenever I’m writing tests, tests fail a lot due to the error

IlluminateDatabaseQueryException: SQLSTATE[55006]: Object in use: 7 FEHLER:  auf Datenbank »tenant_019949ce« wird von anderen Benutzern zugegriffen
DETAIL:  1 andere Sitzung verwendet die Datenbank. (Connection: tenant_host_connection, SQL: DROP DATABASE "tenant_019949ce")

which means the table is used by another user. Tables are created when a tenant is created and should be deleted if a tenant gets deleted but it always fails in tearDown method.

My tests extend TenancyTestCase class:

use IlluminateFoundationTestingTestCase as BaseTestCase;

class TenancyTestCase extends BaseTestCase {

    use RefreshDatabase;

    private Tenant $tenant;

    protected function setUp(): void {
        parent::setUp();

        Config::set('tenancy.seeder_parameters.--class', TestDatabaseSeeder::class);

        $this->setupDefaultTenant();
        $this->forceRootUrl();

        $this->withoutVite();
    }

    private function setupDefaultTenant(): void {

        $this->tenant = Tenant::factory()->create();
        $this->tenant->domains()->save(Domain::factory([
            'domain' => 'tenant',
        ])->make());

        tenancy()->initialize($this->tenant);
    }

    private function forceRootUrl(): void {
        $parsed = parse_url(config('app.url'));
        $host = $parsed['host'] ?? 'localhost.test';
        $port = isset($parsed['port']) ? ':' . $parsed['port'] : '';

        URL::forceRootUrl('https://tenant.' . $host . $port);
    }

    public function tearDown(): void {
        tenancy()->end();
        $this->tenant->delete();

        parent::tearDown();
    }
}

I couldn’t figure out why yet, any ideas on how to fix this?

My goal is to create a single database for each test and delete them if test is completed.

Thank you.

Laravel form submission not saving to database and file uploads not working

I am working on a scholarship management system using Laravel 12, Laravel Breeze, Blade, Tailwind, and MySQL. I created a multi-step applicant form with text fields and file uploads (passport photo, Form 137, certificates, etc.).

When I submit the form, the page reloads but the data is not being saved to the database, and the uploaded files are not stored in the storage/app/public folder.

I expected the form data to be inserted into the database and the uploaded files to be saved in storage, then accessible from the admin dashboard.

I already:

Used enctype=”multipart/form-data” in my form.

Added protected $fillable in my model.

Ran migrations for the fields.

Tried using php artisan storage:link to link storage.

But the problem is still the same: no data is saved, and files don’t upload.

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsApplicationForm;
use IlluminateSupportFacadesAuth;
use IlluminateSupportFacadesStorage;

class ApplicationFormController extends Controller
{
    /**
     * Show the application form for applicants.
     */
    public function create($program)
    {
        // Validate program
        if (!in_array($program, ['DOST', 'CHED'])) {
            abort(404); // If invalid program, show 404
        }

        // Pass the program to your Blade view
        return view('applicant.application-form', compact('program'));
    }

    /**
     * Store a newly created application form in storage.
     */
    public function store(Request $request)
    {
        $validated = $request->validate([
            // Basic info
            'last_name' => 'required|string|max:255',
            'first_name' => 'required|string|max:255',
            'middle_name' => 'nullable|string|max:255',
            'academic_year' => 'nullable|string|max:255',
            'school_term' => 'nullable|string|max:255',
            'application_no' => 'nullable|string|max:255',
            'program' => 'required|string|in:DOST,CHED',

            // Contact / personal details
            'birthdate' => 'nullable|date',
            'gender' => 'nullable|string|max:20',
            'civil_status' => 'nullable|string|max:50',
            'address' => 'nullable|string|max:500',
            'email' => 'nullable|email|max:255',
            'phone' => 'nullable|string|max:50',

            // Academic background
            'bs_field' => 'nullable|string|max:255',
            'bs_university' => 'nullable|string|max:255',
            'bs_scholarship_type' => 'nullable|string|max:255',
            'bs_scholarship_others' => 'nullable|string|max:255',
            'bs_remarks' => 'nullable|string|max:500',

            // Graduate intent
            'grad_field' => 'nullable|string|max:255',
            'grad_university' => 'nullable|string|max:255',
            'grad_plan' => 'nullable|string|max:255',

            // Employment
            'employer_name' => 'nullable|string|max:255',
            'employer_address' => 'nullable|string|max:500',
            'position' => 'nullable|string|max:255',
            'employment_status' => 'nullable|string|max:255',

            // Research & plans
            'research_title' => 'nullable|string|max:500',
            'career_plan' => 'nullable|string|max:500',

            // File uploads
            'passport_picture' => 'nullable|file|mimes:jpg,jpeg,png,pdf|max:4096',
            'form137' => 'nullable|file|mimes:pdf|max:4096',
            'cert_employment' => 'nullable|file|mimes:pdf|max:4096',
            'cert_purpose' => 'nullable|file|mimes:pdf|max:4096',

            'birth_certificate_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'transcript_of_record_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'endorsement_1_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'endorsement_2_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'recommendation_head_agency_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'form_2a_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'form_2b_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'form_a_research_plans_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'form_b_career_plans_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'form_c_health_status_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'nbi_clearance_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'letter_of_admission_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'approved_program_of_study_pdf' => 'nullable|file|mimes:pdf|max:4096',
            'lateral_certification_pdf' => 'nullable|file|mimes:pdf|max:4096',

            // Declaration
            'terms_and_conditions_agreed' => 'nullable|boolean',
            'applicant_signature' => 'nullable|string|max:255',
            'declaration_date' => 'nullable|date',
        ]);

        $application = new ApplicationForm();
        $application->user_id = Auth::id();
        $application->program = $request->program;
        $application->status = 'pending';
        $application->submitted_at = now();

        // Fill non-file fields
        $application->fill(collect($validated)->except([
            'passport_picture',
            'form137',
            'cert_employment',
            'cert_purpose',
            'birth_certificate_pdf',
            'transcript_of_record_pdf',
            'endorsement_1_pdf',
            'endorsement_2_pdf',
            'recommendation_head_agency_pdf',
            'form_2a_pdf',
            'form_2b_pdf',
            'form_a_research_plans_pdf',
            'form_b_career_plans_pdf',
            'form_c_health_status_pdf',
            'nbi_clearance_pdf',
            'letter_of_admission_pdf',
            'approved_program_of_study_pdf',
            'lateral_certification_pdf',
        ])->toArray());

        // File uploads
        $fileFields = [
            'passport_picture',
            'form137',
            'cert_employment',
            'cert_purpose',
            'birth_certificate_pdf',
            'transcript_of_record_pdf',
            'endorsement_1_pdf',
            'endorsement_2_pdf',
            'recommendation_head_agency_pdf',
            'form_2a_pdf',
            'form_2b_pdf',
            'form_a_research_plans_pdf',
            'form_b_career_plans_pdf',
            'form_c_health_status_pdf',
            'nbi_clearance_pdf',
            'letter_of_admission_pdf',
            'approved_program_of_study_pdf',
            'lateral_certification_pdf',
        ];

        foreach ($fileFields as $field) {
            if ($request->hasFile($field)) {
                $path = $request->file($field)->store("uploads/application_forms", "public");
                $application->$field = $path;
            }
        }

        $application->save();

        return redirect()->route('dashboard')
            ->with('success', 'Application form submitted successfully.');
    }

    /**
     * Update an existing application form.
     */
    public function update(Request $request, $id)
    {
        $application = ApplicationForm::findOrFail($id);

        // Ensure only the owner can update
        if ($application->user_id !== Auth::id()) {
            abort(403, 'Unauthorized action.');
        }

        $validated = $request->validate([
            'program' => 'required|string|max:255',
            'school' => 'required|string|max:255',
            'year_level' => 'required|string|max:50',
            'reason' => 'nullable|string|max:1000',
            // file fields
            'passport_picture' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
            'form137' => 'nullable|mimes:pdf,jpg,jpeg,png|max:4096',
            'cert_employment' => 'nullable|mimes:pdf,jpg,jpeg,png|max:4096',
            'cert_purpose' => 'nullable|mimes:pdf,jpg,jpeg,png|max:4096',
        ]);

        // Update normal fields
        $application->program = $validated['program'];
        $application->school = $validated['school'];
        $application->year_level = $validated['year_level'];
        $application->reason = $validated['reason'] ?? $application->reason;

        // Handle file uploads (optional replacement)
        if ($request->hasFile('passport_picture')) {
            $application->passport_picture = $request->file('passport_picture')->store('uploads/passport', 'public');
        }

        if ($request->hasFile('form137')) {
            $application->form137 = $request->file('form137')->store('uploads/form137', 'public');
        }

        if ($request->hasFile('cert_employment')) {
            $application->cert_employment = $request->file('cert_employment')->store('uploads/employment', 'public');
        }

        if ($request->hasFile('cert_purpose')) {
            $application->cert_purpose = $request->file('cert_purpose')->store('uploads/purpose', 'public');
        }

        // Keep status "pending" after edit
        $application->status = 'pending';
        $application->save();

        return redirect()->route('applicant.myApplication')
            ->with('success', 'Your application has been updated and set to Pending.');
    }

    /**
     * Show all applications submitted by the logged-in user.
     */
    public function viewMyApplication()
    {
        $applications = auth()->user()->applicationForms()->latest()->get();
        return view('applicant.my-application', compact('applications'));
    }

    public function edit($id)
    {
        $application = ApplicationForm::findOrFail($id);

        if ($application->user_id !== Auth::id()) {
            abort(403, 'Unauthorized action.');
        }

        return view('applicant.application-edit', compact('application'));
    }
}

Angular – non-existing circular dependency detected (!)

I’m getting the message in console:

Circular dependency detected for MyService. Source: Environment

…however, that service is being injected in only one component, and obviously – that component isn’t injected in service.

This message is listed in console few times, but stack-trace says nothing. Any ideas?

Angular version: 20.x, Vite

stack trace

Set a Viewport to have a margin (or padding) on the right-hand side?

I have a FileMaker file, which uses a web-viewer as a Rich Text Editor. I also have a ‘Slide Control’ which slides a layout object in from one side. When this happens, I run a Function in the RTE which resizes it by adding Padding to one side. I’d like to do the same thing, for a web-viewer that’s being used for browsing the internet.

So essentially, I’m trying to have a clear space to one side of any given web page.

Is this possible to achieve with a Viewport???

This is what I use to resize my RTE:

function changeStyle(PadLeft, PadRight){
var element = document.getElementById('defaultRTE');
element.style.paddingLeft = (PadLeft);
element.style.paddingRight = (PadRight);
}

(NB.. I’m an amateur)

Why does npm run dev fail with “vite is not recognized as an internal or external command” in Laravel 10?

I recently installed a fresh Laravel 10 project with Vite as the frontend build tool. After running composer install and npm install, I tried to start the development server with:

npm run dev

But I get this error on Windows:

'vite' is not recognized as an internal or external command,
operable program or batch file.

I have:

  • Deleted node_modules and re-run npm install.

  • Ensured that vite is listed in devDependencies inside package.json.

  • Tried running npx vite directly, but it shows the same error.

  • Cleared cache with npm cache clean --force.

Expected result: running npm run dev should start the Laravel Vite dev server and compile my assets.

Actual result: it throws the “vite is not recognized” error and does not run.

What is the correct way to fix this issue and ensure npm run dev works properly with Laravel 10 and Vite?

Preflight Request Failure Handling Axios

error image

when i put rate limiting on my server , and when rate exceeds the preflight request fails so code execution stops and interceptor error is also not shown is there any way to handle it in axios , in axios interceptor

 api.interceptors.response.use(
  res => res,
  err => {
    }
  }
);

Different code update with No replies from Gemini

I’ve tested and uploaded my code to the link https://github.com/Dio-Damar-Danendra-Portofolio/Chatbot-Dio-Damar-Danendra (I recently updated on 9:24 A.M in Western Indonesian Time). I have tested with different usernames and I test the messages but it come with the same error message (No reply from Gemini). Please check and revise the errors. (Note: I already set the API key from the https://aistudio.google.com/app/apikey)

I have tested with different usernames and I test the messages but it come with the same error message (No reply from Gemini). I expected to be functional as any other chatbots, but in reality it comes with that Error message from invalid authentication credentials until the reply reads “Error: No reply from Gemini”. I have tried so many solutions.

Make array with osclass custom category while loop

How can i make an array of veriables using a while loop

I am using osclass for a uni project and i find no way whatsoever to make a variable for the custom catagory fields.

I have made Identifiers for the custom catagories and have tried many different approaches to grab and echo the custom catagory value elsewhere on the page other than in the current catagory.

I cannot isolate the custom catagory values by any means.

My only option i am thinking is making or buying a plugin , OR using a PHP veriable array

Below is the code used to display the custom catagory values on my osclass page

<?php if( osc_count_item_meta() >= 1 ) { ?> 
   
          <?php while ( osc_has_item_meta() ) { ?>
          
                    <?php if(osc_item_meta_value()!='') { ?> 
                   
                   
                    // I WOULD LIKE TO MAKE MAKE AN ARRAY OF VERIABLES SO I CAN USE THE CUSTOM CATAGORY DATA 
                    // TRIED SO FAR if(osc_item_meta_name()!='') {  $caughtcountry = osc_item_meta_value('country'); } 
                    // BUT THIS APPROACH DOES NOT WORK 

                    <?php } ?>
            
          <?php } ?>
          
          
      
    <?php } ?>`
    

I have tried using the identifiers that i added to the catagory in Admin panel

I have also tried using the Current PHP but cannot grab the values of specific custom catagories

Below is an example of one of my attempts to grab a custom catagory value but it only shows the 1st value within the values instead of cataching the ‘age’ value using the ‘age’ identifier i used.

 <?php if( osc_count_item_meta() >0 ) {  // The If osc_count_item_meta() >=1 
      if(osc_item_meta_value('age')!='') {  $caughtage = osc_item_meta_value('age'); }  else { $caughtage=''; }
                
    }   else { $caughtage=''; }
     ?>

React Axios POST request returns success but no Preview/Response in Chrome Network DevTools

I am building a signup feature in React. My API is working fine — when I hit the endpoint in Postman or cURL, I get a 201 Created response with JSON.

But in Chrome DevTools → Network tab, when I trigger the API from React, I see 201 Created in the Headers, but in Preview/Response it shows:
Failed to load response data: No data found for resource with given identifier
My Code This is for Sign up Request.

import axios from "axios";
import { useState } from "react";

export default function Signup() {
  const [formData, setFormData] = useState({
    name: "",
    email: "",
    password: ""
  });

  const handleSignUp = async () => {
    try {
      const res = await axios.post("http://localhost:3000/app/users/sign-up", formData);
      console.log("Response:", res.data);
      alert("User created successfully");
    } catch (err) {
      console.error("Signup failed:", err);
    }
  };

  return (
   <form className="mt-8 space-y-6" >
    <div className="rounded-md -space-y-px">
     <div>
      <input
        type="text"
        placeholder="Name"
        value={formData.name}
        onChange={(e) => setFormData({ ...formData, name: e.target.value })}
      />
      <input
        type="email"
        placeholder="Email"
        value={formData.email}
        onChange={(e) => setFormData({ ...formData, email: e.target.value })}
      />
      <input
        type="password"
        placeholder="Password"
        value={formData.password}
        onChange={(e) => setFormData({ ...formData, password: e.target.value })}
      />
      <button type="submit" onClick={handleSignUp}>
        Sign Up
      </button>
    </div>
   </div>
  </form>
     
  );
}

  • What I expected:

    To see the JSON response in the Preview/Response tab in Network DevTools after the request succeeds.

  • What I got:

    The request shows 201 Created in Headers, but Preview/Response says

    Failed to load response data: No data found for resource with given identifier

Why is this happening, and how can I fix it?

How to view the latest version of a kml file in my browser?

I uploaded a kml file to my website and viewed the result in Google Chrome. Then I noticed a waypoint was missing. I added that point to the kml file using Google Earth and then re-uploaded the file. When I reopened the new file in my browser, the added point wasn’t visible. I think it was because a cache (but not the browser cache) was still showing the old version. What should I do to always see the latest version in my browser?

How to save Google Cloud GET Object API mediaLink response to local storage?

I wrote this code that uses Google’s Cloud API to get an object from my bucket and download it. It works perfectly when I had my bucket set to public (allUsers added to Principal w/ all the required roles, then I could just redirect to the mediaLink) but I need it to be more secure. Now I can’t just use the mediaLink to redirect to another tab since that results in an Anonymous user error.

downloadSubmittalBucket(item) {
            this.loading = true

                axios
                .get(`https://storage.googleapis.com/storage/v1/b/bucket-name-here/o/` + item, 
                {
                    headers: { 
                        'Authorization': 'Bearer ' + sessionStorage.getItem("access_token")
                    }
                })
                .then((response) => {
                    // window.open(response.data.mediaLink)
                    this.saveSubmittalBucket(response.data)
                    // console.log(response)
                    

                })
                .catch((err) => {
                    console.log(err)
                });
        },  
saveSubmittalBucket(item){
            axios
                .get(item.mediaLink, 
                {
                    headers: { 
                        'Authorization': 'Bearer ' + sessionStorage.getItem("access_token")
                    }
                })
                .then((response) => {
                    console.log(response)
                    // A bunch of stuff that didn't work:
                    // I've tried using: 
                    // new blob -> filesaver.js
                    // window.open(response.data) -> ends up with anonymous user
                    // base64 -> blob
                    // I've also tried using @google-cloud/storage, unfortunately it doesn't match my use case, since it requires gcloud auth login.
                    // Same with signed URLs, also requires gcloud auth login

                    //Not really sure how this response works too. What is it even?

                })
                .catch((err) => {
                    console.log(err)
                });
}

response.data

So basically the code right now just results in the response above, and I don’t really know how to save it locally. I’ve also looked into using @google-cloud/storage but unfortunately it doesn’t really fit my use case.

Funnily enough, I can download the output just fine using the mediaLink on Postman with the required token, so I’m pretty sure authorization is not an issue.

I’m basically stuck now, don’t really know how to proceed from here.

Any help will be appreciated.

React – Passing event handlers that need arguments as props to child components

I’m new to React, so when I finished the Tic-Tac-Toe Tutorial from the documentation, I started doing the challenges to improve the game and practice. I got stuck at the second challenge:

“2. Rewrite Board to use two loops to make the squares instead of hardcoding them.”

This was the Board component before i started the challenge.

function Board({xIsNext, squares, onPlay}) {

  function handleClick(i) {
    if (squares[i] || calculateWinner(squares)) return;
  
    const nextSquares = squares.slice();
    xIsNext ? (nextSquares[i] = "X") : (nextSquares[i] = "O");
    onPlay(nextSquares)
  }

  const winner = calculateWinner(squares);
  let status;
  status = winner ? "Winner: "+winner : "Next player: "+(xIsNext ? "X" : "O");

  return (
    <>
      <div className="status">{status}</div>
      <div className="board-row">
        <Square value={squares[0]} onSquareClick={() => handleClick(0)} />
        <Square value={squares[1]} onSquareClick={() => handleClick(1)} />
        <Square value={squares[2]} onSquareClick={() => handleClick(2)} />
      </div>
      <div className="board-row">
        <Square value={squares[3]} onSquareClick={() => handleClick(3)} />
        <Square value={squares[4]} onSquareClick={() => handleClick(4)} />
        <Square value={squares[5]} onSquareClick={() => handleClick(5)} />
      </div>
      <div className="board-row">
        <Square value={squares[6]} onSquareClick={() => handleClick(6)} />
        <Square value={squares[7]} onSquareClick={() => handleClick(7)} />
        <Square value={squares[8]} onSquareClick={() => handleClick(8)} />
      </div>
    </>
  );
}

Seeing the pattern that there was in the repetition of the rows and squares, I rewrote the code into this.

function Board({xIsNext, squares, onPlay}) {

  function handleClick(i) {
    if (squares[i] || calculateWinner(squares)) return;
  
    const nextSquares = squares.slice();
    xIsNext ? (nextSquares[i] = "X") : (nextSquares[i] = "O");
    onPlay(nextSquares)
  }

  const squareComponents = []
  const rowComponents = []

  for (i = 0; i < 9; i++) {
    squareComponents.push(<Square key={i} value={squares[i]} onSquareClick={() => handleClick(i)}/>);
  }
  
  for (i = 0; i < 3; i++) {
    rowComponents.push(
      <Row key={i}>
        {squareComponents.splice(0,3)}
      </Row>
    )
  }

  const winner = calculateWinner(squares);
  let status;
  status = winner ? "Winner: "+winner : "Next player: "+(xIsNext ? "X" : "O");

  return (
    <>
      <div className="status">{status}</div>
      {rowComponents}
    </>
  );
}

The page renders, but when you click in any of the squares in the board, the “X” appears only in the fourth square. It’s like all of the click handlers of the Square components are referencing the fourth square. Why does that happen?

My solution to this, after trying many different things, was passing the parameter of the event handler function as a prop to be used in the Square component. So I changed the first for loop in the Board component to this:

squareComponents.push(<Square key={i} value={squares[i]} onSquareClick={handleClick} onSquareClickArgument={i}/>);

And I changed the Square component to this:

function Square(props) {
  return (
    <button className="square" onClick={() => props.onSquareClick(props.onSquareClickArgument)}> 
      {props.value}
    </button>
  );
}

It worked. But why my first solution to this challenge did not and this does?