Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Laravel]DingoAPI i problem z update przez created_at
Lord
post 19.04.2019, 15:46:33
Post #1





Grupa: Zarejestrowani
Postów: 239
Pomógł: 32
Dołączył: 10.03.2004

Ostrzeżenie: (10%)
X----


Korzystam z https://github.com/specialtactics/laravel5-api-boilerplate
Wykorzystuje tam Dingoapi i mam problem z update

  1. $user = User::where('email', 'doc@doc.pl')->first();
  2. $user->password = 'secret1234';
  3. $user->save();

  1. Updating the "createdAt" attribute is not allowed.


  1. vendor/specialtactics/l5-api/src/Models/RestfulModel.php
  2. .....
  3.  
  4. // Disallow updating immutable attributes
  5. if (! empty($model->immutableAttributes)) {
  6. // For each immutable attribute, check if they have changed
  7. foreach ($model->immutableAttributes as $attributeName) {
  8. if ($model->getOriginal($attributeName) != $model->getAttribute($attributeName)) {
  9. throw new BadRequestHttpException('Updating the "'.camel_case($attributeName).'" attribute is not allowed.');
  10. }
  11. }
  12. }
  13.  


Pomoże ktoś? nie wiem w czym jest problem...

Ten post edytował Lord 19.04.2019, 15:47:31
Go to the top of the page
+Quote Post
Pyton_000
post 19.04.2019, 21:34:32
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


W modelu User ustaw

public $immutableAttributes = [];
Go to the top of the page
+Quote Post
Lord
post 23.04.2019, 08:16:30
Post #3





Grupa: Zarejestrowani
Postów: 239
Pomógł: 32
Dołączył: 10.03.2004

Ostrzeżenie: (10%)
X----


Cytat(Pyton_000 @ 19.04.2019, 22:34:32 ) *
W modelu User ustaw

public $immutableAttributes = [];


Dziękuję to naprawiło by błąd, ale problem był gdzie indziej smile.gif miałem observera na modelu User który mieszał sporo i ustawiał inne wartości dla tych pól

Ten post edytował Lord 23.04.2019, 08:17:14
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.03.2024 - 08:21