小编Mar*_*rch的帖子

Laravel:获取要在表格上显示的数组元素

如何获取数组的元素数据?下面是我的对象Tour的数组数据。

\n

某些游览可能没有tour_attendees(空数组)。

\n

一场巡演将只有两条记录(参加者)。

\n
#items: array:3 [\xe2\x96\xbc\n      0 => {#2115 \xe2\x96\xb6}\n      1 => {#3067 \xe2\x96\xb6}\n      2 => {#2125 \xe2\x96\xbc\n        +"id": 12\n        +"schedule_date": "28-11-2021"\n        +"created_at": "2021-11-18T00:16:42.000000Z"\n        +"updated_at": "2022-01-19T08:29:05.000000Z"\n        +"deleted_at": null\n        +"tour_attendees": array:2 [\xe2\x96\xbc           // array data that I want to extract \n          0 => {#3077 \xe2\x96\xb6}                       // attendee #1\n          1 => {#3054 \xe2\x96\xb6}                       // attendee #2\n        ]\n      }\n
Run Code Online (Sandbox Code Playgroud)\n

我想提取数据并放入表中,如下所示。

\n
| No  |    Attendee #1 |     Mobile      |    Attendee #2   |     Mobile      |\n|     | …
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent

2
推荐指数
1
解决办法
513
查看次数

Laravel 8:路由寄存器上的数组到字符串转换

有没有办法在laravel 8中定义路由组的名称?

我正在尝试为卖家建立前往订单管理网站的路线,下面是我在web.php 中的路线列表

use App\Http\Controllers\Seller\OrderController;

Route::group(['prefix' => 'seller', 'middleware' => 'auth', 'as' => 'seller.', 'namespace' => 'Seller'], function () {

    Route::redirect('/','seller/orders');

    Route::resource('/orders',  [OrderController::class]);
});
Run Code Online (Sandbox Code Playgroud)

错误

ErrorException 

Array to string conversion

at C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
412?     protected function getResourceAction($resource, $controller, $method, $options)
413?     {
414?         $name = $this->getResourceRouteName($resource, $method, $options);
415?
? 416?         $action = ['as' => $name, 'uses' => $controller.'@'.$method];
417?
418?         if (isset($options['middleware'])) {
419?             $action['middleware'] = $options['middleware'];
420?         }

1   C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php:416
    Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Array to string conversion", "C:\wamp64\www\my-project\vendor\laravel\framework\src\Illuminate\Routing\ResourceRegistrar.php", ["orders", …
Run Code Online (Sandbox Code Playgroud)

routes laravel

1
推荐指数
2
解决办法
1222
查看次数

标签 统计

laravel ×2

eloquent ×1

php ×1

routes ×1