Laravel OctoberCMSAPI图像路径

Laravel OctoberCMSAPI图像路径,laravel,rest,api,octobercms,Laravel,Rest,Api,Octobercms,我想从我的插件创建API,但API会返回除图像路径以外的所有需要的内容。您知道如何在我的API中获取图像路径并返回吗 在my routes.php中,我有 <?php use Mycompany\ArubaPlaces\Models\Places; Route::get('api/places', function(){ $places = Places::All(); return $places; }); 亚马尔 fields: name: label: Title

我想从我的插件创建API,但API会返回除图像路径以外的所有需要的内容。您知道如何在我的API中获取图像路径并返回吗

在my routes.php中,我有

<?php
use Mycompany\ArubaPlaces\Models\Places;

Route::get('api/places', function(){
$places = Places::All();
return $places;
});
亚马尔

fields:
name:
    label: Title
    span: auto
    required: 1
    type: text
slug:
    label: Slug
    span: auto
    preset:
        field: name
        type: slug
    type: text
description:
    label: Description
    size: small
    oc.commentPosition: ''
    span: full
    type: richeditor
latitude:
    label: Latitude
    span: auto
    required: 1
    type: text
longitude:
    label: Longitude
    span: auto
    required: 1
    type: text
placesimages:
    label: 'Place images'
    mode: image
    useCaption: true
    thumbOptions:
        mode: crop
        extension: auto
    span: full
    type: fileupload

active:
    label: Aktívne
    span: auto
    type: switch
1) 第一个选项是添加
protected$with=['placesimages']
到您的
位置
模型以加载所需的关系,默认情况下,您可以在此处添加多个关系

2) 您可以在查询中进行即时加载,例如
Places::with('placesimages')->get()如果默认情况下不希望立即加载所有文件。在这里,
with
也接受一组关系

如果您确定每次在应用程序中查询要获取图像的位置时,都要选择选项1,否则,只有在查询生成器中指定时,选项2才会获取图像


阅读更多关于

的信息,您得到了什么回应?您也可以添加响应对象吗?{“0”:{“id”:29,“纬度”:“12.574850”,“经度”:“-70.043459”,“名称”:“Arubiana Office”,“描述”:“”,同时具有…

”,“类别”:“category1”,“slug”:“Arubiana”,“排序顺序”:1,“路由id”:null,“路由id”:null,“活动”:1,}
fields:
name:
    label: Title
    span: auto
    required: 1
    type: text
slug:
    label: Slug
    span: auto
    preset:
        field: name
        type: slug
    type: text
description:
    label: Description
    size: small
    oc.commentPosition: ''
    span: full
    type: richeditor
latitude:
    label: Latitude
    span: auto
    required: 1
    type: text
longitude:
    label: Longitude
    span: auto
    required: 1
    type: text
placesimages:
    label: 'Place images'
    mode: image
    useCaption: true
    thumbOptions:
        mode: crop
        extension: auto
    span: full
    type: fileupload

active:
    label: Aktívne
    span: auto
    type: switch