本文整理汇总了PHP中app\Post::whereProviderId方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::whereProviderId方法的具体用法?PHP Post::whereProviderId怎么用?PHP Post::whereProviderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::whereProviderId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionShare
public function actionShare($id)
{
$this->useSession();
$post = Post::whereProviderId($id)->first();
$request = new FacebookRequest($this->session, 'POST', '/me/feed', ['link' => $post->link]);
$response = $request->execute();
$graphObject = $response->getGraphObject();
return $graphObject->getProperty('success');
}
示例2: post
public function post($id)
{
$post = Post::whereProviderId($id)->first();
if ($post) {
return $post;
}
$source = (array) $this->getPost($id);
$postData = array();
foreach ($this->fieldMap as $key => $value) {
$t = null;
if ($value) {
// closure
if (is_object($value) && $value instanceof Closure) {
$t = $value($source);
} else {
if (is_string($value) && isset($source[$value])) {
$t = $source[$value];
} else {
if (is_array($value)) {
foreach ($value as $v) {
if (isset($source[$v]) && strlen($source[$v])) {
$t = $source[$v];
break;
}
}
}
}
}
}
$postData[$key] = $t;
}
if ($postData['posted_at'] && (string) (int) $postData['posted_at'] != $postData['posted_at']) {
$postData['posted_at'] = strtotime($postData['posted_at']);
}
$postData['provider'] = $this->provides;
$postData['provider_id'] = $id;
$postData['user_id'] = $this->user->id;
$postData['meta'] = json_encode($source);
$post = new Post($postData);
$post->save();
return $post;
}