87 questions
1
vote
1
answer
40
views
How can ship multiple different sources for the laravel-vite-plugin besides app.js?
Currently the app has 2 entry points for the JS and CSS files in the blade layout file:
{{-- layout.blade.php --}}
<head>
<meta charset="utf-8" />
<meta name="...
-1
votes
0
answers
86
views
How to authenticate API routes in Laravel 12 using Sanctum [closed]
I have a route which I wish to protect with a token, using Sanctum.
The offending route is /status, which would be accessed by /api/status.
The /foo route works fine, there is only a problem when ...
0
votes
1
answer
104
views
Bug with @foreach loop in Laravel 12.x + Livewire 3.6
I am using Laravel v12 with Filament v4 and TailwindCSS v4.
I wanted to build a site with tabs, witch are a Livewire component inside filament/Page. In this Livewire components I have 3 tabs, where ...
0
votes
1
answer
85
views
How to add routes in laravel 12 [closed]
Fresh new installation of Laravel 12
composer create-project --prefer-dist laravel/laravel api
cd api
composer update
sudo chmod -R 775 storage
sudo chown -R www-data:www-data storage
sudo chmod -R ...
Best practices
0
votes
1
replies
37
views
Ignore parent Model Scope in a Child model
I have two models with global scopes.
#[ScopedBy(UserScope::class)]
class User {}
#[ScopedBy(ViewerScope::class)]
class Viewer extends User {}
The scope just checks if class instance has is_viewer ==...
0
votes
0
answers
37
views
Is it possible to import an entire css folder to the Vite compilation in Laravel 12?
I am using the Laravel 12 + React starter kit, and I want to create several components, for example:
app/resources/js/components/Navbar.tsx
app/resources/js/components/Footer.tsx
app/resources/js/...
0
votes
0
answers
21
views
Laravel 12 + React starter kit - what is the proper way to set the "dir" attribute in the HTML element? [duplicate]
Right now, I can set the lang attribute by changing the value of locale inside /config/app.php, but I also want to set the dir attribute.
I can do something like that inside the /resources/views/app....
0
votes
1
answer
66
views
File not found when trying to display a background image from a CSS file
I have an svg file placed in /public/assets/icons, and I try to use it from within a CSS file:
.some-icon {
background-image: url("/assets/icons/arrow.svg");
}
I get error 404 Not Found ...
Advice
0
votes
0
replies
48
views
How to properly build an HR Management System using Laravel (API) + Next.js (frontend) with token authentication and middleware?
I'm building an HR Management System using:
Backend: Laravel
Frontend: Next.js
Authentication(SPA): Laravel Breeze (already set up for backend)
I'm a beginner in Next.js, and I’m a bit stuck on how ...
Advice
0
votes
5
replies
148
views
Why does Laravel 12 load routes in the bootstrap file instead of RouteServiceProvider
In Laravel 10, we had a RouteServiceProvider class that handled loading up all your different routes. This is a snippet from that file in an older project I worked on using Laravel 10:
...
1
vote
2
answers
182
views
Backend Laravel api and frontend vuejs works in dev but not in production on a shared hosting
I am trying to deploy an application on a shared hosting (LWS).
My app uses Laravel12 as a backend and Vuejs as frontend
The frontend is installed directly on the domain.fr and the backend on a ...
0
votes
1
answer
84
views
How to run Artisan::call() method via Ajax when in maintenance mode
I have upgraded a Lravel 10 app to the latest Laravel 12.36.1.
On the Laravel 10 app I have an Ajax call in the backoffice to put the project down or up that calls a method setMaintenanceMode(string $...
2
votes
1
answer
111
views
Assets not being loaded in Laravel 12 using storage:links
I´ve created a duplicate project of mine to upgrade from Laravel 10 to Laravel 12. As far as the PHP code, routes, and database everything went well as expected.
Yet, in my Laravel 10 project I had my ...
2
votes
1
answer
139
views
How can I append a calculated value to a pivot class at runtime?
I have an Order model that has a many-to-many relation to the Product model:
class Order extends Model
{
//...
public function products(): BelongsToMany
{
return $this->...
3
votes
0
answers
101
views
Implicit model binding fails when using {locale} prefix in routes
I'm working on a multilingual Laravel 12 app. All my routes are grouped under a {locale} prefix, like this:
Route::prefix('{locale}')
->group(function () {
Route::get('/activities/{...
0
votes
1
answer
64
views
Vite built .css file is not being used, page broken as old file is 404
I am using Ubuntu 24.04 and a LEMP stack and vite to host a Laravel 12 application. I am deploying with deployer and running npm run build on the server. Occasionally, I get hit with what seems to be ...
0
votes
1
answer
73
views
How can I set Redis key prefixes for sessions, cache, and queues separately in Laravel 12 (PHP 8.4)?
We’re running a Laravel 12 application (PHP 8.4) using Redis for sessions, cache, and queues — all within a single Redis database.
'redis' => [
'client' => 'phpredis',
'options' => [
...
0
votes
0
answers
24
views
My Laravel 12 spatie laravel-medialibrary - ConversionHasBeenCompletedEvent was not fired in EventServiceProvider
I try to listen to ConversionHasBeenCompletedEvent to delete the original image after the conversion has been completed, but this event did not trigger in my listener.
I'm using spatie laravel-...
5
votes
1
answer
169
views
Set SQL Server LoginTimeout in Laravel
I've encountered a problem in my Laravel 12 project. I usually save my data in a remote SQL Server database, but I have to consider the case of a db server malfunction. I have a backup local ...
0
votes
0
answers
33
views
How to conditionally prefix routes based on user's currency in a web application? [duplicate]
I'm working on a routing system where I need to conditionally prefix all existing routes based on the user's currency. The logic should follow these rules:
If the user's currency is INR, prefix all ...
0
votes
0
answers
77
views
Laravel + Laragon: wrong .env being used for API requests across multiple projects
I’m working locally with Laragon and multiple Laravel projects.
The setup looks like this:
Website A → its own .env (website-a.env), with DB website_a.
Website B → its own .env (website-b.env), with ...
0
votes
1
answer
58
views
dropdown menu not working on jquery in vite laravel 12
i have a project in laravel 12 vita, i installed jquery via npm npm install jquery --save-dec. in navbar layout it shoud display the Languages dropdown using mcamara pakage.
The problem is the ...
0
votes
1
answer
176
views
style css not working after uploading file to a server in laravel 12
I am new in laravel 12. I have a project in laravel 12. My custom CSS file is completely working in localhost after i run npm run dev, then i run npm run build to upload the project to my own server, ...
0
votes
0
answers
56
views
Larave 12 skip and delete related model does to work as inteded [duplicate]
In my Laravel 12 application. This code deletes entire set of logs (related to that app) without skipping:
$app->logs()->orderBy('timestamp_ms', 'desc')->skip(2)->delete();
While this ...
0
votes
1
answer
59
views
can not update data using select statement for where condition
I am trying to update data with where condition. I am trying to get the where condition of update statement from the select statement. But in this case the data is not updated.
public function update(...
0
votes
0
answers
62
views
Laravel 12 – Isolating queues per tenant in a multi-tenant SaaS (database driver)
I’m building a multi-tenant SaaS application with Laravel 12 using the database queue driver.
Problem
Each tenant should have its own isolated queue so that one tenant’s heavy background jobs don’t ...
0
votes
0
answers
29
views
SQLSTATE[HY000] [1040] Too many connections (Connection: mysql, SQL: select * from `cache` where `key` in(job_hubwale_cache_illuminate:queue:restart)) [duplicate]
occurs this error in live project hosted in contabo sesrver
i have create project in laravel12,php 8.2 & database used MySQL. this project hosted in contabo serve in this why generate this error ...
0
votes
0
answers
94
views
Laravel reverb/echo useEchoPublic callback not triggering
I have a feeling I'm doing something very stupid but I cannot get the callback on useEchoPublic to fire no matter what I try
The event is structured like so, this is pulled straight from the browser ...
-1
votes
1
answer
119
views
Calculate the sum total of column values [duplicate]
I have a table in my blade page,
<table>
<thead>
<tr>
<th>Color</th>
<th>Total</th>
</tr>
</thead>
<tbody>
@if ...
1
vote
0
answers
30
views
Laravel 12: Run scheduled command at 07:00 UK time while server is on UTC
I’m using Laravel 12 and I want to run a scheduled command every day at 07:00 UK (Europe/London) time, but my server is configured with UTC timezone.
In my bootstrap/app.php I have and its working:
$...
1
vote
1
answer
43
views
Inertia routes return 404 (Not Found) for app deployed in subfolder
I have deployed a Laravel 12 + Inertia.js (React) app on a shared hosting (cPanel).
The app is located in a subfolder: https://mydomaine/app/.
Authentication routes like:
https://mydomaine/app/login
...
1
vote
1
answer
74
views
On passing json stringify data to controller method shows null
I am trying to post my form data using ajax. I am serializing the form data before posting. But at the controller method, it shows null. There is no problem with the form data because I can pass data ...
-1
votes
2
answers
128
views
Internal Server Error Illuminate\Contracts\Container\BindingResolutionException Target class [admin] does not exist
I'm having this error that I can't seem to resolve. I'm making a Laravel application in PHP.
The routes in the web.php file are correct. There are no errors in the controller, nor in the kernel.php ...
0
votes
2
answers
89
views
How to get inserted model or collection when using fillAndInsert which just returns a boolean?
$transactionsData is an array, and I want the id from transaction id from the transaction model for each item and assign it to the details to insert the id to the transaction item table, how can I ...
-2
votes
2
answers
132
views
Json response not rendering to html table, only shows raw json data [closed]
I am returning json response from index method of my controller class.
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Admin\Services\Finish;
class FinishController ...
1
vote
1
answer
123
views
storage:link not creating symlink in public folder
I'm working on a Laravel 12 project using XAMPP on Windows 10.
I tried to use the following command to create the symbolic link for serving uploaded files:
php artisan storage:link
But the public/...
0
votes
4
answers
180
views
Passing parameter to route function from ajax
I am trying to call a controller method using ajax. But I do not know how to do it? I have tried several ways but can not find the right one.
My controller method::
use App\Http\Controllers\Controller;...
0
votes
1
answer
118
views
load image in select dropdown list
I have a dropdown list, here in the option I want to load image also. I took reference from:
i want to display image in select option dynamically but not working
But the image is not loading. The path ...
-1
votes
1
answer
69
views
Catching errors of model in controller method
I have a controller method which I am using to change the status of the row data in the database. But I forget to mention status field in the model file. So the status was not changing in the database....
1
vote
2
answers
103
views
Laravel Spatie Role/Permission - Integrity constraint violation: 1048 Column 'team_id' cannot be null ---> insert into model_has_roles
I am using Laravel V:12 and Spatie Role/Permission V:6. for multiple roles (super_admin, sub_admin, user, sub_user). I created one seeder for creating an admin user and its role/permission.
At the ...
1
vote
2
answers
961
views
Laravel 12 custom Exception
I want to use different error pages for the admin panel and the frontend in Laravel 12. I created a custom exception class for this purpose, but I haven’t figured out how to activate or use it yet. ...
0
votes
2
answers
65
views
Apply same CSS styles to divs in the arithmetic sequence of three
I have 10 items in my database table. I want to apply same CSS style to the divs in the arithmetic sequence of 3 items.
For example, items [0, 3,6,9] will have CSS style slideInDown, items [1,4,7] ...
-1
votes
1
answer
75
views
using for loop to render image in background image [closed]
I am trying to render an image in my carousel from the database, using a for loop.
But I am stuck on how to use a for loop here, and how to render an image in style="background-image:url.
My code:...
1
vote
1
answer
274
views
Laravel 12 creates a new session on each request
I created a new Laravel 12 application following the Installation guide. The project is generated correctly and I ran all migrations.
When I run php artisan --version I get: Laravel Framework 12.20.0 (...
0
votes
2
answers
86
views
create model and controllers inside specific directory
How to write artisan command to create model and controller inside specific directories.
If I do this command::
php artisan make:model Post -mcr
it create Post controller inside controllers folder, ...
1
vote
1
answer
53
views
retrieve data using where condition and sort in descending order
I am trying to retrieve category (id, category_name, status) table data using where condition and sort in descending order for id. I am writing query like::
public function category()
{
$...
0
votes
1
answer
133
views
Do I still need an Eloquent decimal cast for DECIMAL(10,6) columns in Laravel 12 / PHP 8.2?
I’m building a Laravel 12 e‑commerce site (PHP 8.2).
Product prices are stored in MySQL as DECIMAL(10,6):
base_price DECIMAL(10,6),
profit DECIMAL(10,6)
Many articles recommend adding a cast in ...
1
vote
1
answer
52
views
jquery data table features not working with dynamic table
My datatable is working fine, all the features like pagination, sorting, searching are working with static table data content.
But when I fetch data from database and render in datatable features like ...
1
vote
0
answers
100
views
Schema dump not working in laravel 12 windows
I am trying to dump my mysql schema in laravel project using the following laravel artisan command but gets error on windows 10 machine. I am using windows powershell (PS).
php artisan schema:dump
# ...
1
vote
2
answers
557
views
Middleware exceptions do not work in Laravel 12
I'm doing an online course to learn Laravel, and I have decided to follow it using the latest version of Laravel.
The person on the videos uses an older version of Laravel, so obviously some of the ...