Merge branch 'issue-49' into 'develop'
Comments are now duplicated with products See merge request ldc-web/projets/startcoq!37
This commit is contained in:
commit
317577fb9b
1 changed files with 11 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ use App\Models\Product;
|
|||
use App\Traits\Controllers\HasDocuments;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
|
@ -58,11 +59,12 @@ class ProductController extends Controller
|
|||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param App\Models\Product $productModel
|
||||
* @param App\Models\Product $productModel
|
||||
* @param Illuminate\Support\Collection $commentModel
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function create(Product $productModel): \Illuminate\Contracts\View\View
|
||||
public function create(Product $productModel, Collection $commentModel): \Illuminate\Contracts\View\View
|
||||
{
|
||||
//phpcs:enable
|
||||
$brands = Brand::all();
|
||||
|
|
@ -82,7 +84,8 @@ class ProductController extends Controller
|
|||
'productsFair',
|
||||
'productsShop',
|
||||
'productsCatalog',
|
||||
'keywords'
|
||||
'keywords',
|
||||
'commentModel'
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +258,11 @@ class ProductController extends Controller
|
|||
*/
|
||||
public function duplicate(Product $product)
|
||||
{
|
||||
return $this->create($product->replicate());
|
||||
$duplicatedProduct = $product->replicate();
|
||||
foreach ($product->productComments as $comment) {
|
||||
$duplicatedComments[] = $comment->replicate();
|
||||
}
|
||||
return $this->create($duplicatedProduct, collect($duplicatedComments ?? null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue