47 search results

Token Types & The ApiToken Entity

…used, we want to know which User it's related to. We'll use that during authentication. Calling the property apiTokens is fine and say no to orphan removal. Next property: expiresAt, make that a datetime_immutable and I'll say yes to nullable. Maybe…

5:59
"orphanRemoval" tutorial of this search result https://disq.us/url?url=https%3A%2F%2Fsymfonycasts.com%2Fsearch%3Fq%3DorphanRemoval%3A_VKzVzCMjVfdpjChTu0xHxIjccU&cuid=1175718 you gave is what I was looking for. I have no suggestion, it's already good :). Thanks!
Hi SymfonyCasts, I would like to learn more about "orphanRemoval" topic such as automatically remove orphaned records. If you can please point me to documentation or tutorial. Thank you! Dung.
Thanks for the reply and for the info about the OrphanRemoval option and I will explore it next. For now, for certain learning purposes, I'm trying to get it to work on the database side using the onDelete="CASCADE" Here's what I'm…
Terry Caliendo
Terry Caliendo
Read Full Comment
208 lines | src/Entity/Question.php
// ... lines 1 - 13
class Question
{
// ... lines 16 - 41
#[ORM\OneToMany('question', Answer::class, orphanRemoval: true)]
private Collection $answers;
// ... lines 44 - 206
}
See Code Block in Script
182 lines | src/Entity/Starship.php
// ... lines 1 - 13
class Starship
{
// ... lines 16 - 41
/**
* @var Collection<int, StarshipPart>
*/
#[ORM\OneToMany(targetEntity: StarshipPart::class, mappedBy: 'starship', orphanRemoval: true)]
private Collection $parts;
// ... lines 47 - 180
}
See Code Block in Script
183 lines | src/Entity/Starship.php
// ... lines 1 - 13
class Starship
{
// ... lines 16 - 44
#[ORM\OneToMany(targetEntity: StarshipPart::class, mappedBy: 'starship', fetch: 'EXTRA_LAZY', orphanRemoval: true)]
// ... line 46
private Collection $parts;
// ... lines 48 - 181
}
See Code Block in Script
Hi - thx for the EasyAdmin tutorials - they're super helpful! I had a question/clarification on the `orphanRemoval` piece - per the Answer class, the question id cannot be null (which is why you saw that error when you tried to remove the Answer, failing on…
173 lines | src/Entity/User.php
// ... lines 1 - 22
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
// ... lines 25 - 50
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: DragonTreasure::class, cascade: ['persist'], orphanRemoval: true)]
// ... lines 52 - 53
private Collection $dragonTreasures;
// ... lines 55 - 171
}
See Code Block in Script
…a lot with searching some info about this and other things, e.g. see https://symfonycasts.com/search?q=orphanRemoval - we mention "orphanRemoval" feature in a few screencasts. I hope this helps! If no, please, we would like to hear your feedback what's not covered…
…I will investigate it tomorrow. I did different solution (works but don't like it), but after your answer I have realized that I need orphanRemoval. I did some tests and yes, it works as you explained, I have added these methods and mapped field…
Krzysztof K.
Krzysztof K.
Read Full Comment
Hey toporovvv! Hmm. It's just a matter of asking: what *is* the ideally generated code in this situation (without orphanRemoval)? IF MakeBundle is going to generate a removeComment() method, then what do you think this method should do? If it only removes the Comment…
weaverryan
weaverryan
Read Full Comment
…set up orphanRemoval for the comments field of the Article entity (it's inverse side of the association) and maker bundle does not check, that article_id is mandatory field - it will lead to sql-error in this case. I suppose, that orphanRemoval should be…
toporovvv
toporovvv
Read Full Comment
…properly, try updating your schema. Also you could use the OrphanRemoval option, it's great for OneToOne, you can get more information about it here: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#orphan-removal Or even better…
MolloKhan
MolloKhan
Read Full Comment
Hey Lluís F. That's totally doable and Ryan shows how to do it in this chapter https://symfonycasts.com/screencast/collections/collection-delete-orphan-removal Cheers!
MolloKhan
MolloKhan
Read Full Comment
…uuid_generator')] private ?Uuid $id = null; #[ORM\OneToMany(mappedBy: 'importation', targetEntity: Item::class, cascade: ['persist'], orphanRemoval: true)] private Collection $items; public function __construct() { $this->items = new ArrayCollection(); } public function getId(): ?Uuid { return $this->id; } /** * @return Collection */ public function getItems(): Collection { return $this->items; } …
…this command. It appears to be due to the "purge" command from the fixtures command (when it runs). It appears this command is not intelligently deleting my marketingChannel records. Any idea how I could fix this? I tried orphanRemoval too, but it didn't work.
…ORM\ManyToOne(inversedBy: 'cities')] private ?Country $country = null; #[ORM\OneToMany(mappedBy: 'city', targetEntity: Neighborhood::class, orphanRemoval: true)] private Collection $neighborhoods; For Neighborhood : ``` #[ORM\Column(length: 150)] private ?string $name = null; #[ORM\ManyToOne(inversedBy: 'neighborhoods')] #[ORM\JoinColumn(nullable: false)] private ?City $city = null…
…a removeAsset(Asset $asset), which would find the correct AssignedAsset based on the Asset argument and remove it (you will probably need some orphanRemoval on the relationship for the AssignedAsset to be deleted correctly. If you do all of this and get it working, then…
weaverryan
weaverryan
Read Full Comment
…free the $genusScientist so that another $genus can add it from the edit action, for example. When I use OrphanRemoval the $genusScientist is completely removed, so if a different $genus wants to add it, it needs to re-enter all the $ genusScientist information again…