Compare commits
No commits in common. "bb2b23f4a3914bc1dcf0d6631346facb043127f7" and "5abe69ca5e2bae9910ab9a1b946309f62e51c998" have entirely different histories.
bb2b23f4a3
...
5abe69ca5e
2 changed files with 0 additions and 38 deletions
|
|
@ -18,12 +18,6 @@ class CategorieController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$categories = Categorie::all();
|
||||
|
||||
// Renvoie le nombre d'articles par categorie
|
||||
for($i = 0; $i < count($categories); ++$i) {
|
||||
$categories[$i]['nb_articles'] += Article::where('category_id','=',$categories[$i]->id)->count();
|
||||
}
|
||||
|
||||
return response()->json($categories);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNbArticlesToCategories extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
$table->integer('nb_articles');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('categories', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue