本文整理汇总了PHP中app\models\Tag::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::all方法的具体用法?PHP Tag::all怎么用?PHP Tag::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: composeSidebar
/**
* Compose the sidebar.
*/
private function composeSidebar()
{
view()->composer('partials.sidebar', function ($view) {
$view->with('latest', Article::published()->orderBy('id', 'desc')->take(5)->get());
$view->with('tags', Tag::all());
});
}
示例2: generatePopular
/**
* Generate or regenerate popular Discover Cache items
*
* @param SearchHandlerInterface $searchHandler
* @param CacheHandlerInterface $cacheHandler
*/
public function generatePopular(SearchHandlerInterface $searchHandler, CacheHandlerInterface $cacheHandler)
{
$tags = Tag::all()->groupBy('name')->orderBy('created_at')->take(20)->get();
foreach ($tags as $tag) {
$this->generate($tag, $cacheHandler, $searchHandler);
}
}
示例3: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tags', function (Blueprint $table) {
$table->string('slug')->nullable();
});
//Trigger save on each tag to generate slug
foreach (\App\Models\Tag::all() as $tag) {
$tag->save();
}
}
示例4: getTag
public function getTag()
{
$tags = Tag::all();
return Datatables::of($tags)->edit_column('status', function ($row) {
return showSelectStatus($row->id, $row->status, 'Kacana.product.tag.setStatusTag(' . $row->id . ', 1)', 'Kacana.product.tag.setStatusTag(' . $row->id . ', 0)');
})->edit_column('created', function ($row) {
return showDate($row->created);
})->edit_column('updated', function ($row) {
return showDate($row->updated);
})->add_column('action', function ($row) {
return showActionButton('Kacana.product.tag.showEditTagForm(' . $row->id . ')', 'Kacana.product.tag.removeTag(' . $row->id . ')', true);
})->make(true);
}
示例5: addTags
public function addTags($tags = [])
{
$rowTagsName = Tag::all(['name'])->toArray();
$rowTagsName = array_flatten($rowTagsName);
foreach ($tags as $key => $tag) {
if (in_array($tag, $rowTagsName)) {
} else {
$tag = new Tag();
$tag->name = $tag;
$tag->save();
}
}
}
示例6: testProfileNonEmptySkillsMatrix
/**
* Checks that skills/stars/flags are correct
*
* (Have to decide an ordering here - probably alphabetical on skill name, case-insensitive)
*/
public function testProfileNonEmptySkillsMatrix()
{
$faker = Faker\Factory::create();
factory(App\Models\Profile::class, 'withAUser', 1)->create();
factory(App\Models\Tag::class, 3)->create();
$profile = App\Models\Profile::first();
$rating = 5;
foreach (App\Models\Tag::all() as $tag) {
$seeking = $faker->boolean;
$offering = $faker->boolean;
$profile->add_tag($tag, $rating, $seeking, $offering);
$tags[] = [$tag->name, $rating, $seeking, $offering];
$rating = $rating - 1;
}
$this->visit(route('profile.view', ['name' => $profile->user->username]))->see('seeInElement', '.rating:nth-child(1)', 6)->see('seeInElement', '.rating:nth-child(2)', 4)->see('seeInElement', '.rating:nth-child(3)', 2);
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
$tags = Tag::all();
$skills = Skill::all();
for ($i = 0; $i < 50; $i++) {
$user = User::register($faker->unique()->userName, $faker->unique()->email, bcrypt('password'), 'talent');
$this->userRepository->save($user);
$profileData = ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'location' => $faker->city, 'describe' => $faker->numberBetween(1, count($skills) - 1), 'about' => $faker->sentence(), 'facebook' => $faker->userName, 'linked_in' => $faker->userName, 'twitter' => $faker->userName, 'meetup' => $faker->userName, 'published' => $faker->boolean()];
$userSkills = '';
foreach (range(1, rand(2, 4)) as $x) {
$id = rand(1, count($tags) - 1);
$userSkills .= $tags[$id]->name . ",";
}
$profileData['skills'] = $userSkills;
$this->dispatcher->dispatch(new UpdateProfile($user, $profileData));
}
}
示例8: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$author = User::whereHas('role', function ($q) {
$q->where('slug', 'admin');
})->first();
$categories = Category::where('is_active', 1)->get();
$postsRecents = Post::where('is_active', 1)->where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
$postsPopular = Post::where('is_active', 1)->where('seen', 1)->orderBy('nview', 'desc')->take(3)->get();
$commentsRecents = Comment::where('seen', 1)->orderBy('created_at', 'desc')->take(3)->get();
$tags = Tag::all();
$INFO_SITE = Admin::first();
view()->share('author', $author);
view()->share('categories', $categories);
view()->share('tags', $tags);
view()->share('postsRecents', $postsRecents);
view()->share('postsPopular', $postsPopular);
view()->share('commentsRecents', $commentsRecents);
view()->share('INFO_SITE', $INFO_SITE);
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
$slugify = Slugify::create();
$users = User::all();
$tags = Tag::all();
$skills = Skill::all();
foreach ($users as $user) {
foreach (range(1, rand(2, 3)) as $i) {
$name = $faker->name;
$startup = Startup::create(['name' => $name, 'description' => $faker->text, 'url' => $slugify->slugify($name), 'user_id' => $user->id, 'published' => true]);
$this->repository->save($startup);
$startupTags = [];
foreach (range(1, rand(2, 4)) as $i) {
$id = rand(1, count($tags) - 1);
$startupTags[] = $id;
}
$needs = [];
$commitments = ['full-time', 'part-time'];
foreach (range(1, rand(2, 3)) as $i) {
$roleId = rand(1, count($skills) - 1);
$needTags = [];
foreach (range(1, rand(2, 3)) as $i) {
$id = rand(1, count($tags) - 1);
$needTags[] = $id;
}
$needs[] = array('role' => $roleId, 'quantity' => rand(1, 10), 'skills' => implode(',', $needTags), 'commitment' => $commitments[rand(0, 1)], 'desc' => $faker->text);
$this->repository->updateNeeds($startup, $needs);
}
$startup->tags()->attach($startupTags);
foreach (range(1, rand(2, 3)) as $i) {
$id = rand(1, count($users) - 1);
if ($startup->owner->id !== $id) {
$this->repository->addMemberRequest($users[$id], $startup, false);
if (rand(0, 1)) {
$this->repository->approveMemberRequest($users[$id], $startup, false);
}
}
}
}
}
}
示例10: galeria
function galeria()
{
$posts = \App\Models\Post::all();
$tags = \App\Models\Tag::all();
$tagsUsados = [];
$tagsTotal = [];
$contTags = 0;
$contTagsTotal = 0;
foreach ($posts as $p) {
foreach ($p->tags as $t) {
$tagsUsados[$contTags] = $t->clave;
$contTags++;
}
}
foreach ($tags as $tag) {
$tagsTotal[$contTagsTotal] = $tag->clave;
$contTagsTotal++;
}
$tagsUsadosNeto = array_intersect($tagsTotal, $tagsUsados);
return view('front.galeria')->with(array('posts' => $posts, 'tags' => $tags, 'tt' => $tagsUsadosNeto));
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$tags = Tag::all();
return view('admin.tag.index')->withTags($tags);
}
示例12: getTags
/**
* @param $factId
* @return \Illuminate\Database\Eloquent\Collection|static[]
*/
public function getTags($factId)
{
if (!is_null($factId)) {
$fact = Fact::find($factId);
$fact ? $tags = $fact->tags : ($tags = null);
return $tags;
}
$tags = Tag::all();
return $tags;
}
示例13: all
public function all()
{
return Tag::all();
}
示例14: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$tags = Tag::all();
return view('admin.tags.index')->with('tags', $tags);
}
示例15: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::latest()->get();
$tags = Tag::all();
return view('blog.posts', ['posts' => $posts, 'tags' => $tags]);
}