Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Laravel]DingoAPI i problem z update przez created_at
Forum PHP.pl > Forum > PHP > Frameworki
Lord
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...
Pyton_000
W modelu User ustaw

public $immutableAttributes = [];
Lord
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
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.