{"action":"opened","issue":{"url":"https://api.github.com/repos/laravel/internals/issues/1044","repository_url":"https://api.github.com/repos/laravel/internals","labels_url":"https://api.github.com/repos/laravel/internals/issues/1044/labels{/name}","comments_url":"https://api.github.com/repos/laravel/internals/issues/1044/comments","events_url":"https://api.github.com/repos/laravel/internals/issues/1044/events","html_url":"https://github.com/laravel/internals/issues/1044","id":302014321,"number":1044,"title":"Impossible to make a pivot with a created_at column but no updated_at","user":{"login":"neodc","id":304141,"avatar_url":"https://avatars0.githubusercontent.com/u/304141?v=4","gravatar_id":"","url":"https://api.github.com/users/neodc","html_url":"https://github.com/neodc","followers_url":"https://api.github.com/users/neodc/followers","following_url":"https://api.github.com/users/neodc/following{/other_user}","gists_url":"https://api.github.com/users/neodc/gists{/gist_id}","starred_url":"https://api.github.com/users/neodc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neodc/subscriptions","organizations_url":"https://api.github.com/users/neodc/orgs","repos_url":"https://api.github.com/users/neodc/repos","events_url":"https://api.github.com/users/neodc/events{/privacy}","received_events_url":"https://api.github.com/users/neodc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-03T17:01:54Z","updated_at":"2018-03-03T17:01:54Z","closed_at":null,"author_association":"NONE","body":"With a normal model it's possible to define CREATED_AT but set UPDATED_AT to null when there is only the created_at column and no updated_at column in my table. But in a many to many relation with a pivot it's impossible to use withTimestamps with only one parameter to have the same comportement.\r\n\r\nSince there is no setter for `pivotCreatedAt` in `\\Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany` I had to use this workaround to make my usecase work:\r\n\r\n\t$relation = $this->belongsToMany(User::class, 'table_name')\r\n\t\t->withPivot('pivot_col');\r\n\r\n\t$withCreatedAt = function(string $createdAt)\r\n\t{\r\n\t\t$this->pivotCreatedAt = $createdAt;\r\n\r\n\t\treturn $this->withPivot($this->createdAt());\r\n\t};\r\n\r\n\t$withCreatedAt->call($relation, 'date_added');\r\n\r\n\treturn $relation;\r\n\r\nDo you think it would be possible to make this easier by for example create the methodes withCreatedAt et withUpdatedAt ?"}}
{"actor":{"display_login":"neodc"}}