本文整理汇总了PHP中Sites::images方法的典型用法代码示例。如果您正苦于以下问题:PHP Sites::images方法的具体用法?PHP Sites::images怎么用?PHP Sites::images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sites
的用法示例。
在下文中一共展示了Sites::images方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
function add($request, $response, $args)
{
$add = false;
$body = $request->getParsedBody();
$body['dateStarted'] = $this->formatDate($body['dateStarted']);
if ($body['dateFinished']) {
$body['dateFinished'] = $this->formatDate($body['dateFinished']);
}
$stillUsing = false;
if (isset($body['stillUsing'])) {
$stillUsing = $body['stillUsing'];
}
$site = new Sites();
$result = $site::where('title', $body['title'])->first();
if ($result) {
if ($body['title'] !== $result->title) {
$add = true;
} else {
$error['duplicate'] = $body['title'] . " is already present";
}
} else {
$add = true;
}
if ($add) {
$site->title = $body['title'];
$site->url = $body['url'];
$site->dateStarted = $body['dateStarted'];
$site->dateFinished = $body['dateFinished'];
$site->stillUsing = $stillUsing;
$site->save();
foreach ($body['skills'] as $skill) {
$association = [$skill];
$site->skills()->attach($association);
}
foreach ($body['images'] as $image) {
$association = [$image];
$site->images()->attach($association);
}
}
}