本文整理汇总了PHP中app\models\Post::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::get方法的具体用法?PHP Post::get怎么用?PHP Post::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Post
的用法示例。
在下文中一共展示了Post::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// Following
$deletePosts = $addPosts = $deleteUsers = $addUsers = array();
use app\models\User;
use app\models\Post;
use Exception;
// for clarity's sake
foreach ($data as $userData) {
try {
echo "Looking for User # " . $userData->uid . "\n";
$user = User::get($userData->uid);
echo "User '" . $user . "' found\n";
// following posts
foreach ($userData->posts as $postData) {
list($_pid, $_status) = $postData;
try {
$post = Post::get($_pid);
if ($_status) {
$user->stopFollowingPost($post);
echo "- User '" . $user . "' stopped following Post '" . $post . "'\n";
} else {
$user->startFollowingPost($post);
echo "+ User '" . $user . "' started following Post '" . $post . "'\n";
}
} catch (Exception $ex2) {
// Care!
}
}
// following users
foreach ($userData->users as $followUserData) {
list($_uid, $_status) = $followUserData;
$followUser = User::get($_uid);
示例2: add_post
public function add_post()
{
$validator = models\Post::validator('add');
if (!empty($_POST)) {
if ($validator->validate($_POST)) {
$insert = $validator->output;
$insert['author_id'] = $this->user->UserID();
$insert['created_on'] = time();
if ($pid = models\Post::insert($insert)) {
$post = models\Post::get($pid);
Session::success('Post Created. Look:');
// Send e-mail to $this->user's followers
/* foreach ( $this->user->user->followers AS $user ) {
Email::make($user->email, 'New post by '.$user, $user.' posted a new message on the blog. Read it at '.$post->url(array('absolute' => true)))->send();
}*/
$this->_redirect($post->url());
}
Session::error('Couldn\'t save... =( Try again!?');
}
}
$categories = $validator->options->categories;
$messages = Session::messages();
return $this->tpl->display('blog/post_form', get_defined_vars());
}
示例3: post
public function post($slug)
{
$post = Post::get($slug);
return view('posts.show')->withPost($post);
}