Skip to content

Instantly share code, notes, and snippets.

View ivenms's full-sized avatar

Iven Mathew Simon ivenms

  • Dubai, UAE
View GitHub Profile
@jnbn
jnbn / controller.php
Last active May 17, 2024 03:31
Replicate (Duplicate) Eloquent Model With Relations
<?php
public function replicateWithRelations(QuestionCategory $questioncategory)
{
$newCategory = $questioncategory->replicate();
$newCategory->name = "Kopyası: ".$questioncategory->name;
$newCategory->push();
$questioncategory->relations = [];
//load relations on EXISTING MODEL