本文整理匯總了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);
}