【发布时间】:2018-03-31 11:36:38
【问题描述】:
我想从我的插件创建 API,但 API 返回所有我需要的图像路径。你知道任何人如何获取图像路径并在我的 API 中返回吗?
在我的 routes.php 中有
<?php
use Mycompany\ArubaPlaces\Models\Places;
Route::get('api/places', function(){
$places = Places::All();
return $places;
});
这是我的模型我有这个关系。我的 API 中需要“placeimages”路径:
public $attachMany = [
'placesimages' => 'System\Models\File'
];
fields.yaml
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
【问题讨论】:
-
你得到什么回应?你也可以添加响应对象吗?
-
{ "0": { "id": 29, "latitude": "12.574850", "longitude": "-70.043459", "name": "Arubiana Office", "description": "
虽然...
", "category": "category1", "slug": "arubiana", "sort_order": 1, "routes_id": null, "route_id": null, "活动“:1,}}
标签: laravel rest api octobercms