【发布时间】:2022-01-25 13:58:29
【问题描述】:
我有这个数据库结构:
public function up()
{
Schema::create('skills', function (Blueprint $table) {
$table->id();
$table->string('name',50);
$table->integer('level');
$table->string('description',100);
$table->string('rule',100)->default('main'); // main | other | lang
$table->timestamps();
});
}
现在我想通过 laravel api 资源中的规则对这些数据进行排序
例如,当我调用我的 api 路由时 它应该返回这个:
data{
main [
0 => {
'name' : 'name',
'level' : 'level',
'description' : 'description',
}
],
other [
0 => {
'name' : 'name',
'level' : 'level',
'description' : 'description',
}
],
lang [
0 => {
'name' : 'name',
'level' : 'level',
'description' : 'description',
}
],
}
那我该怎么办呢
我的数据库结构好吗?
ResourceCollection 比资源好?
谢谢
【问题讨论】:
标签: laravel api filter jsonapi-resources