本文整理汇总了PHP中app\Tag类的典型用法代码示例。如果您正苦于以下问题:PHP Tag类的具体用法?PHP Tag怎么用?PHP Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: includeArticles
/**
* Include articles.
*
* @param \App\Tag $tag
* @param \League\Fractal\ParamBag|null $params
* @return \League\Fractal\Resource\Collection
* @throws \Exception
*/
public function includeArticles(Tag $tag, ParamBag $params = null)
{
$transformer = new \App\Transformers\ArticleTransformer($params);
$parsed = $this->getParsedParams();
$articles = $tag->articles()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
return $this->collection($articles, $transformer);
}
开发者ID:linuxssm,项目名称:l5essential,代码行数:15,代码来源:TagTransformer.php
示例2: tagged
/**
* Display a listing of the resource associated with the tag name.
*
* @param Tag $tag
* @return \Illuminate\Http\Response
*/
public function tagged(Tag $tag)
{
$admin = User::first();
$tags = Tag::all();
$articles = $tag->publishedArticles()->get();
$currentTag = $tag;
return view($this->theme() . 'home', compact('articles', 'currentTag', 'admin', 'tags'));
}
开发者ID:realnerdo,项目名称:portfolio,代码行数:14,代码来源:ThemeController.php
示例3: show
public function show(Tag $tag)
{
$articles = $tag->articles()->published('<')->get();
// if published date is not required then
// below line can be used :)
// $articles = $tag->articles
return view('articles.index', compact('articles'));
}
开发者ID:sriharsha-sammeta,项目名称:learn-laravel-5.2,代码行数:8,代码来源:TagsController.php
示例4: store_tag
public function store_tag(Request $request)
{
$name = $request->name;
$tag = new Tag();
$tag->name = $name;
$tag->save();
return redirect('manage/producttags');
}
开发者ID:Kaelcao,项目名称:colormev2,代码行数:8,代码来源:TagController.php
示例5: seedTags
private function seedTags($faker)
{
foreach (range(0, 100) as $number) {
$tag = new Tag();
$tag->name = $faker->word;
$tag->save();
}
}
开发者ID:alexbonavila,项目名称:taskAPI,代码行数:8,代码来源:DatabaseSeeder.php
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Tag $tag)
{
if (Auth::user() && Auth::user()->isAdmin()) {
$posts = $tag->post()->simplePaginate(10);
} else {
$posts = $tag->post()->publics()->simplePaginate(10);
}
return view('tags.show', compact('posts', 'tag'));
}
开发者ID:khaled-barca,项目名称:MyTunnelVision,代码行数:15,代码来源:TagController.php
示例7: seedTags
private function seedTags($faker)
{
foreach (range(0, 100) as $number) {
$tag = new Tag();
$tag->title = $faker->word;
// $tag->onoff =$faker->boolean;
$tag->save();
}
}
开发者ID:OscarDuranX,项目名称:tasksAPI,代码行数:9,代码来源:DatabaseSeeder.php
示例8: store
public function store(TagRequest $request)
{
//$this->createTags($request);
$tag = new Tag();
$tag->name = $request->input('name');
$tag->save();
\Session::flash('flash_message', 'Tag has been added!');
return redirect('tags');
}
开发者ID:chrisguo1,项目名称:To-Do-List,代码行数:9,代码来源:TagsController.php
示例9: seedTags
public function seedTags($faker)
{
foreach (range(0, 100) as $number) {
$tag = new Tag();
$tag->name = $faker->word;
$tag->random_bool = $faker->boolean;
$tag->save();
}
}
开发者ID:albertmayor,项目名称:tasksAPI,代码行数:9,代码来源:DatabaseSeeder.php
示例10: seedTags
private function seedTags($faker)
{
foreach (range(0, 100) as $item) {
$tag = new Tag();
$tag->title = $faker->word;
// $tag->prova = $faker->boolean();
$tag->save();
}
}
开发者ID:Germangalia,项目名称:tasksAPI,代码行数:9,代码来源:DatabaseSeeder.php
示例11: sendTags
private function sendTags($faker)
{
foreach (range(0, 100) as $number) {
$tag = new Tag();
$tag->name = $faker->word;
//$tag->tran = $faker->boolean;
$tag->save();
}
}
开发者ID:pdavila13,项目名称:tasksAPI2,代码行数:9,代码来源:DatabaseSeeder.php
示例12: seedTags
/**
* @param Faker $faker
*/
private function seedTags(Faker $faker)
{
foreach (range(0, 100) as $item) {
$tag = new Tag();
$tag->name = $faker->world;
$tag->prova = $faker->boolean();
$tag->save();
}
}
开发者ID:rogermelich,项目名称:tasksAPI,代码行数:12,代码来源:DatabaseSeeder.php
示例13: destroy
public function destroy(Tag $tag)
{
if (!$tag->transactions->isEmpty()) {
flash()->error('Tag cannot be removed while in use');
return redirect()->route('tag.index');
}
$tag->delete();
flash()->success('Tag removed successfully');
return redirect()->route('tag.index');
}
开发者ID:albarincon,项目名称:money-manager,代码行数:10,代码来源:TagController.php
示例14: all
public function all()
{
$tag = new Tag();
$all = Tag::all(['id', 'tag as text']);
if (\Input::has('isWeekly')) {
$weeklyTag = $tag->getRecentlyWeeklyTag();
return ['tags' => $all, 'wrTag' => $weeklyTag];
}
return $all;
}
开发者ID:suzumi,项目名称:giita,代码行数:10,代码来源:TagController.php
示例15: show
public function show(Tag $tag)
{
// if (Gate::denies('update', $tag)) {
// abort(403, Message::HTTP_403);
// }
// $this->authorize('update', $tag);
// if (auth()->user()->can('update', $tag)) {
// return 'You can';
// }
$articles = $tag->articles()->paginate(5);
return view('articles.index', compact('articles'));
}
开发者ID:Ravend6,项目名称:laravel_learn,代码行数:12,代码来源:TagsController.php
示例16: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$tag = new Tag();
$tag->name = "news";
$tag->slug = "news";
$tag->save();
$tag = new Tag();
$tag->name = "Technology";
$tag->slug = "Technology";
$tag->save();
$tag = new Tag();
$tag->name = "sports";
$tag->slug = "sports";
$tag->save();
}
开发者ID:jatinverma007,项目名称:MY-FIRST-PROJECT-ON-LARAVEL,代码行数:20,代码来源:TagController.php
示例17: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
$router->bind('articles', function ($id) {
$article = Article::findOrFail($id);
// If the owner return all articles else return only published.
if (Auth::user() && $article->user_id === Auth::user()->id) {
$articles = Article::findOrFail($id);
} else {
$articles = Article::published()->findOrFail($id);
}
return $articles;
});
$router->bind('questions', function ($id) {
return Question::findOrFail($id);
});
$router->bind('answers', function ($id) {
return Answer::findOrFail($id);
});
$router->bind('tags', function ($name) {
return Tag::where('name', $name)->firstOrFail();
});
$router->bind('users', function ($id) {
return User::findOrFail($id);
});
}
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:33,代码来源:RouteServiceProvider.php
示例18: edit
public function edit(Article $article)
{
$tags = Tag::lists("name", "id");
$published_at = Carbon::now();
$usert = $article->getTagListAttribute();
return view('articles.edit', compact('article', 'usert', 'published_at', 'tags'));
}
开发者ID:bordeau,项目名称:l5l,代码行数:7,代码来源:ArticleController.php
示例19: postImport
public function postImport(Request $req)
{
$color = ['red', 'pink', 'blue', 'purple', 'green', 'yellow', 'indigo', 'cyan', 'lime', 'brown', 'orange', 'gray'];
$data = [];
$status = true;
if ($req->input('tags')) {
$data = explode("\n", $req->input('tags'));
for ($i = 0; $i < count($data); $i++) {
list($cate, $name) = explode('-', $data[$i]);
$category = DB::table('categories')->where('name', $cate)->first();
$cateId = 0;
if ($category) {
$cateId = $category->id;
} else {
$cateId = DB::table('categories')->insertGetId(['name' => $cate, 'color' => $color[rand(0, count($color) - 1)]]);
}
$tag = Tag::where('name', $name)->first();
if ($tag) {
$tag->category_id = $cateId;
$tag->save();
} else {
Tag::create(['name' => $name, 'category_id' => $cateId]);
}
}
}
return ['status' => $status, 'tags' => $this->getIndex()];
}
开发者ID:newset,项目名称:wx,代码行数:27,代码来源:Tags.php
示例20: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
/**
* Binding the model
*/
// $router->model('articles', 'App\Article');
/**
* Optional custom bind
*/
$router->bind('articles', function ($id) {
/**
* Show only the published articles
*/
return \App\Article::published()->findOrFail($id);
});
// $router->model('tags', 'App\Tag');
$router->bind('tags', function ($name) {
/**
* Show only the related same tag by name
*/
return \App\Tag::where('name', $name)->firstOrFail();
});
}
开发者ID:rudbast,项目名称:laravel-tutorial,代码行数:31,代码来源:RouteServiceProvider.php
注:本文中的app\Tag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论