Laravel-data is a 3rd party Laravel package developed by Spatie. The package enables the creation of rich data objects which can be used in various ways. Using this package you only need to describe your data once.
Questions tagged [laravel-data]
10 questions
3
votes
1 answer
How to properly use Spatie\LaravelData for retrieveing data?
I was introduced to Spatie\LaravelData when I was searching for how to implement DTOs in Laravel.
Using Data classes for insert/update for a single model is pretty straightforward. I tend to keep my updates atomic in this way.
However I have a…

Lamar
- 1,761
- 4
- 24
- 50
1
vote
1 answer
Laravel addSelect
I have a query, and I'm trying to add a addSelect() to it, but it won't work, and I don't know why, according to the docs it seems correct
The query:
return Project::query()
->with('client')
->with('status')
->with('tasks')
…

Telexx
- 420
- 2
- 11
1
vote
2 answers
Is it possible to ignore a laravel-data object property when converting to a model?
I am using spatie/laravel-data to work with some data that eventually gets inserted into the database.
One of the things I need to do is sum up and average some things while I'm doing calculations, and I have (maybe unwisely) stored the running sum…

Offlein
- 665
- 6
- 22
0
votes
0 answers
Is it possible to dynamically type the HandleInertiaRequest share function?
I'd like to dynamically type the HandleInertiaRequest share function using Spatie Laravel Data and the Typescript transformer.
This is to have a dynamic type that I can use in my front-end to type the usePage.
My first idea was that Middleware from…

WantyJF
- 29
- 4
0
votes
1 answer
Create upload file test with Laravel Excel
I use Spatie Laravel Data and maatwebsite Laravel Excel.
My test need use specific xlsx file stored inside my tests folder. I've seen a lot of test used fake files but I can't use one because it's special template.
I try to create test to upload…

WantyJF
- 29
- 4
0
votes
0 answers
is it possible to have a custom attribute with spatie/laravel-data?
I have a really simple Data written as the following
use Spatie\LaravelData\Data;
class FrequencyData extends Data
{
public function __construct(
public string $type,
public bool $hasEndDate,
public string $repeat,
…

nzmattman
- 465
- 3
- 15
0
votes
0 answers
Yajra datatable Search is not working when "serverSide: true"
When "serverSide: true" then the search option works not perfectly.
My table has 5000+ records, I'm using "serverSide: true" for fast data load, but the search not working. Again when using serverSide: false then the search works perfectly but the…

Hanif Mia Fabel
- 19
- 1
- 7
0
votes
1 answer
Creating Laravel DTO from request with optional fields
I'm using Spatie Laravel-data to create data objects to pass in and out of an API. I'm hitting an issue trying to create a DTO from a POST request - there are certain fields that won't be passed in for an INSERT, the obvious one being ID.
I'm…

charliefortune
- 3,072
- 5
- 28
- 48
0
votes
1 answer
Spatie Laravel/data not formatting errors
I'm working on a project in which I'm using Spatie's laravel-data package (https://spatie.be/docs/laravel-data/v2/introduction) to manage Data Transfer Objects (DTOs). I've got some DTOs which are currently working fine until I got to this one in…

MrCujo
- 1,218
- 3
- 31
- 56
0
votes
1 answer
Laravel Ignore not working for unique validation rule
I'm working on a simple API using Laravel. At the moment working on the update endpoint for my categories resource. A name for a category must be unique and that seems to be working just fine, but when performing an update it is failing even though…

MrCujo
- 1,218
- 3
- 31
- 56