我如何使用多个Eloquent With()?
PortalPlaylistElement模型
class PortalPlaylistElement extends Model
{
public $primaryKey = 'code';
public $incrementing = false;
public $timestamps = false;
public function AirtimePlaylists()
{
return $this->hasOne('App\AirtimePlaylist','id','playlist_id');
}
}
Run Code Online (Sandbox Code Playgroud)
AirtimePlaylistContent模型
class AirtimePlaylistContent extends Model
{
protected $table = 'cc_playlistcontents';
}
Run Code Online (Sandbox Code Playgroud)
AirtimePlaylistModel
class AirtimePlaylist extends Model
{
protected $table = 'cc_playlist';
public function PortalPlaylistElements()
{
return $this->belongsTo('App\PortalPlaylistElement','playlist_id');
}
public function AirtimePlaylistContents()
{
return $this->hasMany('App\AirtimePlaylistContent','playlist_id');
}
}
Run Code Online (Sandbox Code Playgroud)
我没有遇到任何问题:
AirtimePlaylist::with('AirtimePlaylistContents')->get());
Run Code Online (Sandbox Code Playgroud)
要么
PortalPlaylistElement::with('AirtimePlaylists')->get();
Run Code Online (Sandbox Code Playgroud)
但我想在属于PortalPlaylistElement的AirtimePlaylist中获取所有AirtimePlaylistContents.
本质上,(伪代码)
PortalPlaylistElement::with('AirtimePlaylists')::with('AirtimePlaylistContents')->get();
Run Code Online (Sandbox Code Playgroud) 所以我正在学习并了解 swift/google 地图 API。但是,无论我尝试什么,当我点击标记时,我都无法让打印语句出现在控制台中。
点击标记会显示标记名称,但它永远不会打印。我尝试了在网上找到的 private func 的一些变体,但也许我在这里遗漏了一些更基本的东西......
import UIKit
import GoogleMaps
class ViewController: UIViewController, GMSMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
struct MarkerStruct {
let name: String
let lat: CLLocationDegrees
let long: CLLocationDegrees
}
let markers = [
MarkerStruct(name: "Food Hut 1", lat: 52.649030, long: 1.174155),
MarkerStruct(name: "Foot Hut 2", lat: 52.649030, long: 1.174185),
]
let camera = GMSCameraPosition.camera(withLatitude: 52.649030, longitude: 1.174155, zoom: 14)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.delegate = self
self.view = mapView
for marker …Run Code Online (Sandbox Code Playgroud) 屏幕截图中的列表组现在可以滚动 - 完美,但我希望它们占据剩余页面高度的 100%。我尝试了 100vh - 由于页面上的其他组件而没有运气。100% 高度会忽略滚动并用整页滚动列出所有内容。调整 'vh' 以获得正确的值让我很接近,但重新调整大小却将其丢弃了少量。
我想我可能需要使用 flexbox 使列表组填充页面的其余部分,但到目前为止我还没有成功。
https://jsfiddle.net/aq9Laaew/128800/
<body>
<style>
.list-group {
height: 70vh;
overflow-y: scroll;
}
</style>
<main role="main" class="container-fluid">
<div class="row" style="font-size: 10pt;">
<div class="col-sm">
<div class="card">
<div class="card-header">
<strong>Notices</strong>
</div>
<ul class="list-group list-group-flush">
@foreach($notices as $notice)
<li class="list-group-item">
{{ $notice['body'] }}<br/>
<small class="text-muted float-right">{{ $notice['datetime'] }} by {{ $notice['user_id'] }}</small>
</li>
@endforeach
</ul>
</div>
</div>
// ADDITIONAL COL-SM'S
</main>
Run Code Online (Sandbox Code Playgroud)