Sorry for the question but i have this very simple problem.
I made a query like this:
$firstPlanned = Posts::where('status', 'planned')->first();
Then i try to update this Post like this:
$firstPlanned->title = 'New title for this post';
$firstPlanned->updated_at = Carbon::now();
$firstPlanned->save();
I expected that in the collection only this document (the first taken in query) will be updated with the new data.
But I'm wrong and I'm getting all Posts in status 'planned' updated.
Do I do something wrong, or is there a bug in the procedure?
Sorry for the question and thanks in advance for your time.
Regards
Alessandro
Try to do:
plannedDone,
I get the same result.
Thanks
Alessandro
Why did you closed this?
The problem is always there.!!
Hi @alexandre-butynski ,
can you show us the Posts model?
what do you see dumping $firstPlanned after the following line of code?
$firstPlanned = Posts::where('status', 'planned')->first();
If you leave the default configuration, Laravel already set up this line for you:
$firstPlanned->updated_at = Carbon::now();
Done,
I get the same result.
Thanks
Alessandro
Show code for model, please
This is my model:
namespace App;
use Jenssegers\Mongodb\Eloquent\Model;
use Laravel\Scout\Searchable;
class post extends Model
{
protected $connection = 'mongodb';
protected $collection = 'posts';
protected $fillable = [
'owner_id',
'group_id',
'title',
'content',
'status',
'updated_at',
'created_at',
];
}
`
namespace App;
use Jenssegers\Mongodb\Eloquent\Model;
use Laravel\Scout\Searchable;
class post extends Model
{
protected $connection = 'mongodb';
protected $collection = 'posts';
protected $fillable = [
'owner_id',
'group_id',
'title',
'content',
'status',
'updated_at',
'created_at',
];
}`
Why did you closed this?
The problem is always there.!!
Hello,
Please be kind, we are trying to help you, it's really hard to take care of all issues at once, %99 of them are like this without much information.
Provide more information, give an example and let us to take care of it.
Thank you!
Is this related to this https://github.com/jenssegers/laravel-mongodb/pull/1565 ?
@alextesi https://github.com/Smolevich/demo-mongo-application/pull/10/files i prepare PR with creating three Post models and update one of them after creating
Console commad: TestPost
php artisan test:post -iIf you have some specific things, you can describe in linked PR for quick investigation problem
https://github.com/jenssegers/laravel-mongodb/issues/1919#issuecomment-577195855 there is section one use which is never used Laravel\Scout\Searchable; in your code block
Can it be the problem, i want to implement it, but it's not yet done.
@alextesi, i suggest to implement minimal example here. Yet i don't understand that problem in this library. If https://github.com/Smolevich/demo-mongo-application/pull/10/files isn't all logic, please notify me or @divine
Closing due to inactivity, please let us know when you'll have more information.
Thanks.
Most helpful comment
Hello,
Please be kind, we are trying to help you, it's really hard to take care of all issues at once, %99 of them are like this without much information.
Provide more information, give an example and let us to take care of it.
Thank you!