本文整理汇总了PHP中app\models\Tag::getTags方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::getTags方法的具体用法?PHP Tag::getTags怎么用?PHP Tag::getTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::getTags方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTags
public function getTags($id)
{
$tmp = array();
$postTags = Post_tags::getPostTags($id);
// print_r (count($postTags->getModels()));
for ($i = 0; $i < count($postTags->getModels()); $i++) {
array_push($tmp, $postTags->getModels()[$i]['tag_id']);
}
// print_r($tmp);
$tags = implode("','", $tmp);
$getTags = Tag::getTags($tags);
//print_r($getTags->getModels());
return $getTags;
}
示例2: category
/**
* Get category and category posts
*
* @param Request $request
* @param $alias
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function category(Request $request, $alias)
{
$category = Category::getCategoryByAlias($alias);
if (empty($category)) {
return redirect()->back();
} else {
$tags = Tag::getTags();
if (!session()->get($category['id'])) {
$category_visit = new CategoryVisit();
$category_visit->category_id = $category['id'];
$category_visit->save();
session([$category['id'] => $category['id']]);
}
$posts = Category::getCategoryApprovedPosts($category['id'], 5, $request->input('search'), $request->input('tag'));
$request->flash();
return view('site.category', compact('category', 'posts', 'tags'));
}
}
示例3: export
/**
* Export tags
*/
public function export()
{
$data = array(array('Name'));
$tags = Tag::getTags();
foreach ($tags as $tag) {
$tag_array = array();
$name = $tag['name'];
array_push($tag_array, $name);
array_push($data, $tag_array);
}
Excel::create('Tags', function ($excel) use($data) {
$excel->sheet('Tags', function ($sheet) use($data) {
$sheet->fromArray($data, null, 'A1', false, false);
$sheet->cells('A1', function ($cells) {
$cells->setFontWeight('bold');
});
});
})->export('xls');
}
示例4: edit
/**
* Edit post
*
* @param Request $request
* @param int $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function edit(Request $request, $id = 0)
{
$post = Post::getPostById($id);
if (empty($post)) {
return redirect()->back();
} else {
if ($request->isMethod("post")) {
$rules = ["title" => "required", "alias" => "required|unique:posts,alias," . $id, "content" => "required", 'image' => 'mimes:jpeg,jpg,png'];
Validator::make($request->all(), $rules)->validate();
$post->title = $request->input("title");
$post->alias = $request->input("alias");
$post->content = $request->input("content");
$post->meta_keys = $request->input("meta_keys");
$post->meta_desc = $request->input("meta_desc");
if (!empty($request->file("image"))) {
if (!empty($post->image)) {
if (Storage::exists('uploads/' . $post->image) && Storage::exists('uploads/fb-' . $post->image)) {
Storage::delete('uploads/' . $post->image, 'uploads/fb-' . $post->image);
}
}
$generated_string = str_random(32);
$file = $request->file("image")->store('uploads');
$new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension();
Storage::move($file, 'uploads/' . $new_file);
$img = Image::make($request->file('image'));
$img->crop(200, 200);
$img->save(storage_path('app/public/uploads/' . $new_file));
$img = Image::make($request->file('image'));
$img->resize(600, 315);
$img->save(storage_path('app/public/uploads/fb-' . $new_file));
$post->image = $new_file;
}
if ($request->has("category")) {
$post->category_id = $request->input("category");
}
$post->publish = $request->has("publish");
$post->save();
$new_tags = [];
if ($request->has("tags")) {
$tags = $request->input("tags");
foreach ($tags as $tag) {
array_push($new_tags, $tag);
}
}
$post->tags()->sync($new_tags);
return redirect()->route('posts');
} else {
$categories = Category::getCategoriesByPublish();
$tags = Tag::getTags();
return view("site.post.edit", compact("post", "categories", "tags"));
}
}
}
示例5: actionEdit
public function actionEdit($id)
{
$request = Yii::$app->getRequest();
$me = Yii::$app->getUser()->getIdentity();
$model = $this->findTopicModel($id, ['content', 'node']);
if (!$me->canEdit($model)) {
throw new ForbiddenHttpException('您没有权限修改或已超过可修改时间。');
}
if ($me->isAdmin()) {
$model->scenario = Topic::SCENARIO_ADMIN_EDIT;
} else {
$model->scenario = Topic::SCENARIO_AUTHOR_EDIT;
}
if (!($content = $model->content)) {
$content = new TopicContent(['topic_id' => $model->id]);
}
$oldTags = $model->tags;
if ($model->load($request->post()) && $model->validate() && $content->load($request->post()) && $content->validate()) {
// $model->tags = Tag::editTags($model->tags, $oldTags);
$model->tags = Tag::getTags($model->tags);
$model->save(false) && $content->save(false);
Tag::afterTopicEdit($model->id, $model->tags, $oldTags);
(new History(['user_id' => $me->id, 'action' => History::ACTION_EDIT_TOPIC, 'action_time' => $model->updated_at, 'target' => $model->id]))->save(false);
return $this->redirect(Topic::getRedirectUrl($id, 0, $request->get('ip', 1), $request->get('np', 1)));
}
return $this->render('edit', ['model' => $model, 'content' => $content]);
}
示例6: actionList
/**
* 显示所有的tag标签
*/
public function actionList()
{
return $this->render('list', ['tags' => Tag::getTags(1)]);
}
示例7: foreach
<?php
/**
* @author xbzbing <xbzbing@gmail.com>
* @link http://www.crazydb.com
*/
use yii\web\View;
use yii\helpers\Url;
use app\models\Tag;
/* @var View $this */
$tags = Tag::getTags(false, 20);
$colors = ['default', 'primary', 'success', 'info', 'warning', 'danger'];
?>
<div class="widget aside-tags">
<h3 class="widget_tit with-shadow">
<i class="glyphicon glyphicon-tags"></i>标签
</h3>
<div class="with-shadow">
<?php
if ($tags) {
foreach ($tags as $tag) {
$color = $colors[mt_rand(0, 5)];
echo <<<HTML
<a href="{$tag['url']}" title="{$tag['name']}({$tag['totalCount']})" target="_blank">
<span class="label label-{$color}">{$tag['name']}</span>
</a>
HTML;
}
} else {
echo '<span class="label label-default">暂无标签</span>';