33 lines
754 B
PHP
33 lines
754 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Article;
|
|
use App\Models\ArticleCategory;
|
|
|
|
class TestController extends Controller
|
|
{
|
|
|
|
public function index()
|
|
{
|
|
|
|
}
|
|
|
|
public function set_article_category()
|
|
{
|
|
$articles = Article::whereHas('category')
|
|
->chunk(200, function ($articles) {
|
|
foreach ($articles as $article) {
|
|
ArticleCategory::create([
|
|
'article_id' => $article->id,
|
|
'category_id' => $article->category_id,
|
|
]);
|
|
}
|
|
});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|