diff --git a/.idea/blade.xml b/.idea/blade.xml
new file mode 100644
index 0000000..ddb9fb5
--- /dev/null
+++ b/.idea/blade.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/composerJson.xml b/.idea/composerJson.xml
new file mode 100644
index 0000000..4199499
--- /dev/null
+++ b/.idea/composerJson.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/laravel5-jsonapi.iml b/.idea/laravel5-jsonapi.iml
new file mode 100644
index 0000000..c956989
--- /dev/null
+++ b/.idea/laravel5-jsonapi.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ddbd9da
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..5523ee8
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,705 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php b/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
index ab13384..713b6d5 100644
--- a/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
+++ b/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiController.php
@@ -102,8 +102,10 @@ public function store(Request $request)
$model = $this->getDataModel();
$data = (array) $request->get('data');
- $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString();
- $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString();
+ if (array_key_exists('attributes', $data) && $model->timestamps) {
+ $data['attributes'][$model::CREATED_AT] = Carbon::now()->toDateTimeString();
+ $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString();
+ }
return $this->addHeaders(
$resource->get($data, get_class($this->getDataModel()), $createResource)
diff --git a/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php b/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
index 7bfc8b5..2e7e94e 100644
--- a/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
+++ b/src/NilPortugues/Laravel5/JsonApi/Controller/JsonApiTrait.php
@@ -10,6 +10,7 @@
namespace NilPortugues\Laravel5\JsonApi\Controller;
+use Carbon\Carbon;
use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
@@ -197,10 +198,16 @@ protected function patchAction(Request $request, $id)
$resource = new PatchResource($this->serializer);
+ $model = $this->getDataModel();
+ $data = (array) $request->get('data');
+ if (array_key_exists('attributes', $data) && $model->timestamps) {
+ $data['attributes'][$model::UPDATED_AT] = Carbon::now()->toDateTimeString();
+ }
+
return $this->addHeaders(
$resource->get(
$id,
- (array) $request->get('data'),
+ $data,
get_class($this->getDataModel()),
$find,
$update