All Questions
16,712 questions
1
vote
1
answer
57
views
How to set a default value of 1 year from now for expire_at in Laravel migrations? [duplicate]
I am creating fields for a table in Laravel. I want to create a expire_at column using $table->timestamps() but set a default date of 1 year from now.
Currently, I am trying the following:
$table-&...
0
votes
0
answers
46
views
Using MySQL 'utf8mb4' but getting "Malformed UTF-8 characters, possibly incorrectly encoded"
I have a project created in Laravel v10.48.20 and I'm using Laravel Nova v4.34.3 to show records.
I recently added some records with some German characters, and now the Nova resource is throwing this ...
-3
votes
0
answers
32
views
Try Catch not handling database integrity constraint violation [duplicate]
Summary
I have a laravel eloquent project which utilizes MySQL database with a constraint set up to
require for name && count field to form a unique composite field.
Problem
With this in ...
1
vote
1
answer
34
views
Laravel Eloquent Query Using Case/When to apply conditions dynamically
I am trying to apply a different set of date filter depending on the values of the start_date and end_date column of the robot table
Condition
If robot start date && robot end date are both ...
-1
votes
0
answers
16
views
Why laravel/spatie query builder filters with null value dosen't work [duplicate]
I tried to filter my query builder with a null value
I did this :
return QueryBuilder::for(Invoice::class)
->allowedIncludes('equipments')
->allowedFilters(
...
-1
votes
1
answer
59
views
How to resolve "ambiguous column" error in Laravel Livewire PowerGrid filter with joined tables?
I'm using Laravel Livewire with PowerGrid v2.x and have a query that joins multiple tables to display transaction data. Both transactions and invoices tables contain a transaction_type column, which ...
1
vote
1
answer
28
views
Use value in table as part of Laravel RawQuery searching for results within X radius of coordinates
I currently have a fixed radius of 50km, which is an ENV constant, for finding all users within X radius of a particular set of coordinates. What I would like to achieve is allowing users to set their ...
2
votes
3
answers
87
views
Laravel Eloquent Query Running So SLOWLY as compared to mySQL counterpart
Why is this laravel eloquent query running so SLOWLY?
I have a query running in a Laravel job that executes very slowly and inconsistently. Sometimes it takes 1-2 minutes to fetch the result, while at ...
0
votes
1
answer
83
views
How to match Laravel models with multiple conditions using one query
I am building a Laravel application where I keep track of the earned commissions of sales agents within my company. Everytime a sale is made a record is created in the scores database table (Score ...
0
votes
1
answer
46
views
Laravel query builder: How to perform calculation on withSum() column?
I have these Models:
Product Model:
protected $fillable = ['id', 'name', 'qty', 'parent_id'];
public function parent() {
return $this->belongsTo(self, 'parent_id');
}
public function children() ...
0
votes
0
answers
31
views
Database Conflict in Multiple Docker Compose Setups
I have two LAMP stacks for each of my laravel app branches. Each branch is in a different folder. The setups run in a container with the following docker compose files:
1)
version: "3.1"
...
0
votes
2
answers
68
views
Join and OrderBy statement very slow, 77 seconds, despite indexes
I'm having performance issues with MySQL, despite having indexes when using both join and order by . The query is currently taking 77 seconds to complete.
The purpose of the query is to order the ...
0
votes
0
answers
97
views
Encryption and Searching JSON Data using Laravel
I'm working on a system that stores users' data in a JSON format. An example of table structure and JSON format is shown below.
Visitor Id
Visitor Name
JSON Data
101
John
{JSON_DATA_SHOWN_BELOW}
...
0
votes
2
answers
117
views
I have a problem connecting laravel to my database even if i enabled pdo_mysql [duplicate]
This is the error when i try to run php artisan migrate:
Illuminate\Database\QueryException
could not find driver (Connection: mysql, SQL: select exists (select 1 from information_schema....
0
votes
1
answer
49
views
Merging Two Laravel Collections with Same Keys for Aggregation has performance issue
I'm currently working on a Laravel application that merges statistics from two collections: postStats (a standard Collection) and contentStats (a LazyCollection). The mergeStats method I'm using ...
0
votes
0
answers
68
views
How safely to make on filament / mysql site global search is case insensitive? [duplicate]
On laravel / filament / mysql site global search is case insensitive.
I can not edit eloquent queries like :
Model::whereRaw("UPPER('{$column}') LIKE '%'". strtoupper($value)."'%'")...
-3
votes
1
answer
55
views
Laravel Sail - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
Anyone knows why this query is returning error? I'm using Laravel Sail with Mysql version: 8.0.32, it should work:
Property::select(DB::raw("
properties.id,
properties....
0
votes
1
answer
40
views
Laravel Paginate with OrderByRaw return different order
I am facing a very weird issue where my query return a different order depending on the pagination size:
$query->orderByRaw("CASE WHEN tracking_eta IS NOT NULL THEN tracking_eta ELSE ...
0
votes
0
answers
44
views
Laravel: Column stays NULL on insert on production, not on my local machine
My script (a Laravel job) takes the path of an uploaded file (.pdf) and transforms it into a .jpg file name. When the script inserts everything to the database, all fields are added correctly, except ...
0
votes
1
answer
68
views
Laravel/ MySQL basic audit using triggers
For an API using Laravel and MySQL we are trying to setup an audit mechanism using MySQL triggers.
We've extended Illuminate\Database\DatabaseManager with something like
public function connection(...
0
votes
0
answers
18
views
Ilumination Server Error Access denied for user 'root'@'localhost' [duplicate]
[tolongin perbaiki laravel saya dan beri tahu cara nya
Internal Server Error
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (...
0
votes
1
answer
48
views
cannot connect laravel with mysql inside a docker container [duplicate]
I have laravel 11 application and it works fine. I want the application to run inside docker and I have the following docker file set up for the laravel app:
FROM php:8.3-fpm
RUN apt-get update &&...
-4
votes
1
answer
61
views
Not getting unpaid or partially paid records some can help me? [closed]
$draw = intval($request->draw);
$start = intval($request->start);
$length = intval($request->length);
$order = $request->order;
$search = $request->search;
$search = $search['value'];
$...
1
vote
1
answer
60
views
How to sort/order query based on presence in array in laravel?
I want to sort/order a query in laravel. For example I have a model where 'id' ranges from 1 to 100. And I have an array of ids of selected model elements eg. [1,3,12,32,...].
I want to sort my model ...
0
votes
0
answers
27
views
In plesk how to make the larvel app create a database
In plesk how to make the larvel app create a database , i have try this put did not work on the server
DB::statement("CREATE DATABASE $databaseName");
DB::statement("CREATE USER '$...
0
votes
1
answer
57
views
Selected Option Not Displayed in Dropdown Placeholder After Fetching Data
I'm working on a project where I'm fetching data from a database using a Laravel API. The data is used to populate a dynamic dropdown list. When I select an option from the dropdown, the correct data ...
0
votes
0
answers
35
views
Laravel with Docker: Migration Fails for Second Database with SQLSTATE[HY000] [2002] Connection timed out Error
I'm working on a Laravel project where I need to connect to multiple MariaDB databases using Docker. While I can successfully connect to the first database and run migrations, I'm encountering an ...
0
votes
1
answer
98
views
laravel sail cannot start mysql
I am trying to run laravel sail in a project I have inherited, I run vendor/bin/sail up --build
And for some reason it cannot start the DB instance? I get the error
[InnoDB] Cannot boot server ...
0
votes
0
answers
37
views
Encountering Error 1025 When Adding Foreign Key in Laravel Migration [duplicate]
am trying to add a foreign key to the mahasiswa table that references the prodi and jurusan tables in my Laravel project. Here is my migration code:
public function up()
{
Schema::table('mahasiswa'...
-1
votes
1
answer
76
views
How to merge two query into a single query in Laravel? [duplicate]
In my application, I have two similar pages where one page has data with group by and another page has without group by. Here is the code for without group by
$posts = Product::where('category_id', ...
1
vote
0
answers
57
views
Hosted Shopify app on Heroku responding with server 500 error (SQLSTATE[HY000] [2002] Connection refused) [duplicate]
I have a Shopify app hosted on Heroku that is responding with a server 500 error (this error is not triggered by any specific line of code or human interaction).
I believe the issue is with MySQL is ...
0
votes
1
answer
60
views
(Laravel 11) errno: 150 "Foreign key constraint is incorrectly formed [duplicate]
I need to do a relation between the tables citizen and nuclear_Family, this is intended so they can fulfill a form of their family information, that will be linked to a citizen folder that works with ...
0
votes
0
answers
35
views
Getting "Invalid datetime format: 1292 Incorrect datetime value: '2024-08-19T19:24:44.000000Z' for column 'created_at' at row 1" [duplicate]
Environment:
PHP 8.1.6 (cli) (built: May 11 2022 08:55:59) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
MySQL
Mysql Ver 8.2.0 for Win64 on ...
0
votes
0
answers
56
views
Why Are My Counts Different Using selectRaw vs Collection Methods in Laravel?
Description:
I’m encountering a discrepancy between two methods for counting records in Laravel, and I’m trying to understand why the results are different despite the logic being similar.
Context:
I ...
-3
votes
2
answers
93
views
when a foreign key references a primary key in the same table in mysql
In laravel referral system i want two foreign keys(userId,parentId) if user registers using referral code
I defined two foreign keys (userId,parentId) in the network table when a user registers with ...
0
votes
0
answers
48
views
Laravel Docker: SQLSTATE[HY000] [2002] Connection timed out
I'm trying to connect mysql database but it's not work. How to fix it?
.env file
DB_CONNECTION=mysql
DB_HOST=host.docker.internal
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=sail
DB_PASSWORD=password
...
2
votes
0
answers
48
views
Why am I getting a "Duplicate entry" error for an email that doesn't exist in my DB of the Laravel app?
I'm working on a Laravel project and encountered a strange issue when trying to insert a new user into the users table. The error I’m seeing is:
SQLSTATE[23000]: Integrity constraint violation: 1062 ...
0
votes
0
answers
21
views
How in laravel make group by date of created_at field? [duplicate]
On laravel / mysql 8 site I need to get date where there are more rows by day with created_at datetime field With request :
$reactions = Reaction
::groupBy('created_at')
->orderBy('...
0
votes
0
answers
41
views
Laravel5.7 issue in saving longtext to database
I have a laravel5.7 function that save data in database, it have 1 longtext field, and that saves the data to database very well. Now i have created a new table with the name of history, it is almost ...
-1
votes
1
answer
47
views
laravel model pages not communicating properly
Working on a client project, hit a setback.
Laravel is reading
"Call to undefined relationship [service_item] on model [App\Models\Service]".
It's simply trying to read data from two ...
0
votes
1
answer
51
views
Eloquent ORM performance with subqueries for relational models
Laravel eloquent uses subqueries for relationship model instead of joins as joins offer more optimal performance .How does eloquent orm ensures performance for relational models ?
0
votes
1
answer
39
views
Laravel app getting "[1045] Access denied for user 'root'@'172.19.0.4'" error when connecting to MySQL Docker container
I'm facing an issue connecting my Laravel application to a MySQL Docker container. When I run php artisan migrate, I'm getting the following error:
SQLSTATE[HY000] [1045] Access denied for user 'root'...
0
votes
0
answers
48
views
Laravel passport slow query
Im using Laravel 10 (PHP 8.3) with MySQL database. The Laravel apps is deployed on server A, and the MySQL deployed in server B. For the first 3 weeks, the performance is awesome, but per today the ...
0
votes
1
answer
246
views
Unable to log in as mysql root user in Laravel Sail
I'm trying to grant privileges to my "sail" mysql user, but when I log in as root it is logging me in as sail instead.
I should note that I can connect to mysql fine in PHPStorms db browser (...
-2
votes
2
answers
117
views
Why can't my laravel database be found now even if I had already used it a few days ago?
I'm new to using the laravel framework, and I'm struggling in starting my project due to several problems I've encountered while setting up. I'm currently using Linux as my command prompt and Xampp ...
1
vote
2
answers
519
views
MySQL docker container stuck reloading
My stack is win10/wsl2/ubuntu/docker desktop.
I'm stuck on running a MySQL docker container.
This is a part of my docker-compose.yml:
mysql:
hostname: a-mysql
container_name: a-...
0
votes
1
answer
101
views
Laravel Controller Not handling FormData from React Frontend
I am working on a ReactJS frontend and a Laravel backend. My ReactJS frontend sends FormData to a Laravel controller for updating an event. The FormData is correctly populated on the frontend before ...
-1
votes
2
answers
619
views
Base table or view not found: 1146 Table 'example_app.sessions' doesn't exist
I am trying to set up Laravel 11 on Windows 11. I am using WAMPServer for Apache/PHP/MySql.
I have installed the installer globally using Composer. I then run this command to create a Laravel project:
...
0
votes
1
answer
92
views
Error: 1826 Duplicate foreign key constraint name 'id'
I've created a basic database structured as follows.
vehicle_makes (id, name, slug)
vehicle_models (id, name, slug, make_id)
vehicle_trims (id, name, slug, model_id)
When attempting to create the ...
0
votes
1
answer
114
views
Laravel queued job fails with different exceptions after 5-20 minutes of execution
The job is loading a huge 100M CSV into mysql table via LOAD DATA INFILE.
After different periods of working the job fails
App\Jobs\UpdateProducts ................... 17m 43s FAIL
but remains in jobs ...