Showing
3 changed files
with
32 additions
and
8 deletions
| ... | @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; | ... | @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; |
| 6 | use App\Models\Immerse; | 6 | use App\Models\Immerse; |
| 7 | use App\Models\PackPoem; | 7 | use App\Models\PackPoem; |
| 8 | use Illuminate\Http\Request; | 8 | use Illuminate\Http\Request; |
| 9 | -use Illuminate\Support\Facades\Validator; | ||
| 10 | use Jiannei\Response\Laravel\Support\Facades\Response; | 9 | use Jiannei\Response\Laravel\Support\Facades\Response; |
| 11 | 10 | ||
| 12 | class HomeController extends Controller | 11 | class HomeController extends Controller |
| ... | @@ -14,15 +13,33 @@ class HomeController extends Controller | ... | @@ -14,15 +13,33 @@ class HomeController extends Controller |
| 14 | /** | 13 | /** |
| 15 | * Display a listing of the resource. | 14 | * Display a listing of the resource. |
| 16 | * | 15 | * |
| 16 | + * @param Request $request | ||
| 17 | * @return \Illuminate\Http\JsonResponse | 17 | * @return \Illuminate\Http\JsonResponse |
| 18 | */ | 18 | */ |
| 19 | - public function index() | 19 | + public function index(Request $request) |
| 20 | { | 20 | { |
| 21 | - // admin video | 21 | + $page = $request->get('page',1); |
| 22 | - $lists = Immerse::query()->paginate(10); | 22 | + $page_size = $request->get('page_size',5); |
| 23 | - | 23 | + $lists = Immerse::query()->skip(($page - 1) * $page_size)->take($page_size + 1)->get(); |
| 24 | - // user video | 24 | + $data = []; |
| 25 | - return Response::success($lists); | 25 | + foreach ($lists as $list) { |
| 26 | + $data[] = [ | ||
| 27 | + 'id' => $list->id, | ||
| 28 | + 'user_id' => $list->user_id, | ||
| 29 | + 'title' => $list->title, | ||
| 30 | + 'content' => $list->content, | ||
| 31 | + 'url' => $list->url, | ||
| 32 | + 'type' => $list->type, | ||
| 33 | + 'poem_id' => $list->poem_id, | ||
| 34 | + 'temp_id' => $list->temp_id, | ||
| 35 | + 'bgm' => $list->bgm, | ||
| 36 | + 'praise' => $list->praise, | ||
| 37 | + 'view' => $list->view, | ||
| 38 | + 'collect' => $list->collect, | ||
| 39 | + 'share' => $list->share, | ||
| 40 | + ]; | ||
| 41 | + } | ||
| 42 | + return Response::success($data); | ||
| 26 | } | 43 | } |
| 27 | 44 | ||
| 28 | 45 | ... | ... |
| ... | @@ -89,7 +89,7 @@ class ImmerseController extends Controller | ... | @@ -89,7 +89,7 @@ class ImmerseController extends Controller |
| 89 | MakeVideo::dispatch($create, $validated['item_url']); | 89 | MakeVideo::dispatch($create, $validated['item_url']); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - return Response::created($create); | 92 | + return Response::success($create); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /** | 95 | /** | ... | ... |
| ... | @@ -15,6 +15,13 @@ class Immerse extends Model | ... | @@ -15,6 +15,13 @@ class Immerse extends Model |
| 15 | 15 | ||
| 16 | protected $guarded = ['']; | 16 | protected $guarded = ['']; |
| 17 | 17 | ||
| 18 | + protected $casts = [ | ||
| 19 | + 'user_id' => 'integer', | ||
| 20 | + 'type' => 'integer', | ||
| 21 | + 'poem_id' => 'integer', | ||
| 22 | + 'temp_id' => 'integer', | ||
| 23 | + ]; | ||
| 24 | + | ||
| 18 | public function send($user_id, $type, $audio = '', $video = '') | 25 | public function send($user_id, $type, $audio = '', $video = '') |
| 19 | { | 26 | { |
| 20 | 27 | ... | ... |
-
Please register or login to post a comment