当前位置: 首页>>代码示例>>PHP>>正文


PHP Content::where方法代码示例

本文整理汇总了PHP中Content::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::where方法的具体用法?PHP Content::where怎么用?PHP Content::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Content的用法示例。


在下文中一共展示了Content::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $x = 1;
     foreach (Group::all() as $group) {
         $contents = Content::where('group_id', $group->getKey())->count();
         $entries = Entry::where('group_id', $group->getKey())->count();
         $total = $contents + $entries;
         // Default activity is medium = 2
         $group->activity = 2;
         // Low activity, when nothing was added last week
         if ($total == 0) {
             $group->activity = 1;
         }
         if ($total > 15) {
             $group->activity = 3;
         }
         if ($total > 50) {
             $group->activity = 4;
         }
         $group->save();
         if (!($x % 100)) {
             $this->info($x . ' groups processed');
         }
         $x++;
     }
     $this->info('All groups processed');
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:32,代码来源:GroupActivity.php

示例2: show

 public function show($groupName)
 {
     $group = Group::name($groupName)->with('creator')->firstOrFail();
     $group->checkAccess();
     $stats = ['contents' => intval(Content::where('group_id', $group->getKey())->count()), 'comments' => intval(Content::where('group_id', $group->getKey())->sum('comments')), 'entries' => intval(Entry::where('group_id', $group->getKey())->count()), 'banned' => intval(GroupBanned::where('group_id', $group->getKey())->count()), 'subscribers' => $group->subscribers, 'moderators' => intval(GroupModerator::where('group_id', $group->getKey())->count())];
     return array_merge($group->toArray(), ['stats' => $stats]);
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:7,代码来源:GroupController.php

示例3: newsItem

 public function newsItem($newsItem)
 {
     $newsItemParts = explode('-', $newsItem);
     $newsItem = Content::where('type', 'news')->where('id', $newsItemParts[0])->get();
     $recent = Content::where('type', 'news')->where('subtype', null)->orderBy('date', 'DESC')->limit(3)->get();
     return View::make('new')->withContent($newsItem)->withRecent($recent);
 }
开发者ID:TheCompleteCode,项目名称:laravel-kdc,代码行数:7,代码来源:HomeController.php

示例4: factory

 public static function factory($id = null)
 {
     $instance = new Content();
     if (!empty($id)) {
         $instance->where('id', $id)->get();
     }
     return $instance;
 }
开发者ID:jotavejv,项目名称:CMS,代码行数:8,代码来源:content.php

示例5: edit

 public function edit($id)
 {
     $query = Content::where('id', $id);
     if ($query->count() == 1) {
         return View::make('Dashboard.ContentManagement.Edit', array('row' => $query));
     } else {
         return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Nothing found</p>');
     }
 }
开发者ID:jorzhikgit,项目名称:MLM-Nexus,代码行数:9,代码来源:ContentManagement.php

示例6: index

 public function index()
 {
     $data['can_save'] = $this->perm->can_create;
     save_logs($this->menu_id, 'View', $this->session->userdata("id"), ' View explanation ');
     $rs = new Content();
     $data['rs'] = $rs->where("slug", "explanation")->get(1);
     $data['menu_id'] = $this->menu_id;
     $this->template->build("contents/form", $data);
 }
开发者ID:ultraauchz,项目名称:conference,代码行数:9,代码来源:contents.php

示例7: Content

 function move_down()
 {
     $cont = new Content();
     //$cont->where('parent_section',$this->parent_section );//same section
     $cont->where('parent_content', $this->parent_content);
     //same parent
     $cont->where('cell', $this->cell);
     // same cell
     $cont->where('sort >', $this->sort);
     //greater sort
     $cont->get();
     //get them to process
     // if that content object exists then that place is taken
     // so we have to get a place for it
     if ($cont->exists()) {
         $this->deattach();
         $this->sort++;
         $this->attach();
         return TRUE;
     }
     return FALSE;
 }
开发者ID:sigit,项目名称:vunsy,代码行数:22,代码来源:content.php

示例8: addVote

 public function addVote(Content $content)
 {
     $poll = $content->poll;
     // No double voting, sorry
     $hasVoted = in_array(Auth::id(), array_column($poll['votes'], 'user_id'));
     if ($hasVoted) {
         return Redirect::route('content_comments', $content->getKey())->with('danger_msg', 'Oddałeś już głos w tej ankiecie.');
     }
     // Check if poll isn't closed already
     if (isset($poll['ends_at']) && Carbon::now()->gte($poll['ends_at'])) {
         return Redirect::route('content_comments', $content->getKey())->with('danger_msg', 'Ankieta została już zakończona.');
     }
     // Create validation rules for all questions
     $rules = [];
     foreach ($poll['questions'] as $questionId => $question) {
         $rules[$questionId] = ['array', 'min:' . $question['min_selections'], 'max:' . $question['max_selections']];
         if ($question['min_selections']) {
             $rules[$questionId][] = 'required';
         }
     }
     // Now validate replies
     $validator = Validator::make(Input::all(), $rules, ['required' => 'Odpowiedź na to pytanie jest wymagana', 'min' => 'Zaznaczyłeś zbyt małą liczbę odpowiedzi', 'max' => 'Zaznaczyłeś zbyt dużą liczbę odpowiedzi']);
     if ($validator->fails()) {
         return Redirect::route('content_comments', $content->getKey())->withInput()->withErrors($validator);
     }
     // And add vote object to poll
     $replies = [];
     foreach ($poll['questions'] as $questionId => $question) {
         $optionIds = (array) Input::get($questionId);
         foreach ($optionIds as $optionId) {
             if (!in_array($optionId, array_column($question['options'], '_id'))) {
                 return Redirect::route('content_comments', $content->getKey())->withInput()->with('danger_msg', 'Wygląda na to, że jedna z odpowiedzi została usunięta. Spróbuj jeszcze raz.');
             }
         }
         $replies[$questionId] = $optionIds;
     }
     foreach ($replies as $questionId => $optionIds) {
         if (!$optionIds) {
             continue;
         }
         foreach ($optionIds as $optionId) {
             Content::where('_id', $content->getKey())->where('poll.questions.' . $questionId . '.options', 'elemmatch', ['_id' => $optionId])->increment('poll.questions.' . $questionId . '.options.$.votes', 1);
         }
     }
     $vote = ['created_at' => new MongoDate(), 'user_id' => Auth::id(), 'replies' => $replies];
     $content->push('poll.votes', $vote);
     return Redirect::route('content_comments', $content->getKey())->with('success_msg', 'Twój głos został dodany.');
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:48,代码来源:PollController.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     DB::connection()->disableQueryLog();
     foreach (Group::all() as $group) {
         $builder = Content::where('group_id', $group->getKey())->orderBy('uv', 'desc')->take(50);
         $count = $builder->count();
         //$averageUv = $builder->avg('uv');
         if ($count < 10) {
             $threshold = 2;
         } else {
             $threshold = $this->median($builder->lists('uv'));
             $threshold = round($threshold);
             $threshold = max(2, $threshold);
         }
         $group->popular_threshold = $threshold;
         $group->save();
     }
 }
开发者ID:strimoid,项目名称:strimoid,代码行数:23,代码来源:UpdateThresholds.php

示例10: createDefaultContent

 public function createDefaultContent()
 {
     $existing = \Content::where('is_home', 1)->first();
     if ($existing == false) {
         $content = new \Content();
         $content->title = "Home";
         $content->url = 'home';
         $content->parent = 0;
         $content->is_home = 1;
         $content->is_active = 1;
         $content->content_type = "page";
         $content->subtype = "static";
         $content->layout_file = "index.php";
         $content->save();
         $menu = new \Menu();
         $menu->title = "header_menu";
         $menu->item_type = "menu";
         $menu->is_active = 1;
         $menu->save();
         $menu = new \Menu();
         $menu->parent_id = 1;
         $menu->content_id = 1;
         $menu->item_type = "menu_item";
         $menu->is_active = 1;
         $menu->save();
         $menu = new \Menu();
         $menu->title = "footer_menu";
         $menu->item_type = "menu";
         $menu->is_active = 1;
         $menu->save();
         $menu = new \Menu();
         $menu->parent_id = 2;
         $menu->content_id = 1;
         $menu->item_type = "menu_item";
         $menu->is_active = 1;
         $menu->save();
     }
 }
开发者ID:Git-Host,项目名称:microweber,代码行数:38,代码来源:TemplateInstaller.php

示例11: anyTree

 public function anyTree()
 {
     $id = \Input::all();
     if (@$id['id'] == '#') {
         $id = '';
     } else {
         $id = @$id['id'];
     }
     if (!$id) {
         $id = $this->content->fromApplication()->whereNull('parent_id')->first()->id;
     }
     $config = \Config::get('bootlegcms.cms_tree_descendents');
     $tree = $this->content->where('id', '=', $id)->first();
     $tree = $config != null ? $tree->getDescendants($config) : $tree->getDescendants();
     $tree = $tree->toHierarchy();
     if (count($tree)) {
         foreach ($tree as $t) {
             $treeOut[] = $this->renderTree($t);
         }
         return response()->json($treeOut);
     } else {
         return response()->json();
     }
 }
开发者ID:ryzr,项目名称:bootlegcms,代码行数:24,代码来源:ContentwrapperController.php

示例12: createSlug

 public static function createSlug($input, $parent, $ignoreDuplicates = false)
 {
     if (@$input['name']) {
         $pageSlug = $input['name'];
     } else {
         $pageSlug = uniqid();
     }
     $pageSlug = str_replace(" ", "-", $pageSlug);
     //spaces
     $pageSlug = urlencode($pageSlug);
     //last ditch attempt to sanitise
     $wholeSlug = rtrim(@$parent->slug, "/") . "/{$pageSlug}";
     if ($ignoreDuplicates) {
         return $wholeSlug;
     }
     //does it already exist?
     if (Content::where("slug", "=", $wholeSlug)->first()) {
         //it already exists.. find the highest numbered example and increment 1.
         $highest = Content::where('slug', 'like', "{$wholeSlug}-%")->orderBy('slug', 'desc')->first();
         $num = 1;
         if ($highest) {
             $num = str_replace("{$wholeSlug}-", "", $highest->slug);
             $num++;
         }
         return strtolower("{$wholeSlug}-{$num}");
     } else {
         return strtolower($wholeSlug);
     }
 }
开发者ID:niallkatana,项目名称:bootlegcms,代码行数:29,代码来源:Content.php

示例13: news

 public function news()
 {
     $content = Content::where('type', 'news')->where('subtype', null)->orderBy('date', 'DESC')->paginate(5);
     $recent = Content::where('type', 'news')->where('subtype', null)->orderBy('date', 'DESC')->limit(3)->get();
     return View::make('client.news')->withContent($content)->withRecent($recent);
 }
开发者ID:TheCompleteCode,项目名称:laravel-kdc,代码行数:6,代码来源:ClientController.php

示例14: Content

<?php

$c = new Content();
$c->where('slug', NULL)->or_where('slug', '')->limit(100)->get_iterated();
foreach ($c as $content) {
    $content->slug = '__generate__';
    $content->save();
}
$c = new Content();
if ($c->where('slug', NULL)->or_where('slug', '')->count() === 0) {
    $done = true;
}
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:12,代码来源:0012.php

示例15: INT

$fields = $this->db->query("SHOW COLUMNS FROM {$t->table}");
$run = true;
if ($fields) {
    $result = $fields->result();
    if ($result && strtolower($result[0]->Type) === 'int(9)') {
        $run = false;
    }
}
if ($run) {
    $this->db->query("TRUNCATE TABLE {$t->table}");
    $this->db->query("ALTER TABLE {$t->table} DROP COLUMN count");
    $this->db->query("ALTER TABLE {$c->table} DROP COLUMN count");
    $this->db->query("ALTER TABLE {$t->table} DROP COLUMN id");
    $this->db->query("ALTER TABLE {$t->table} ADD id INT(9) AUTO_INCREMENT PRIMARY KEY FIRST");
    $a = new Album();
    $c = new Content();
    $t = new Text();
    $this->db->query("ALTER TABLE {$a->table} DROP COLUMN tags_migrated");
    $this->db->query("ALTER TABLE {$c->table} DROP COLUMN tags_migrated");
    $this->db->query("ALTER TABLE {$t->table} DROP COLUMN tags_migrated");
    $this->db->query("ALTER TABLE {$a->table} ADD tags_migrated TINYINT(1) DEFAULT 0");
    $this->db->query("ALTER TABLE {$c->table} ADD tags_migrated TINYINT(1) DEFAULT 0");
    $this->db->query("ALTER TABLE {$t->table} ADD tags_migrated TINYINT(1) DEFAULT 0");
    $this->db->query("ALTER TABLE {$a->table} CHANGE tags tags_old TEXT");
    $this->db->query("ALTER TABLE {$c->table} CHANGE tags tags_old TEXT");
    $this->db->query("ALTER TABLE {$t->table} CHANGE tags tags_old TEXT");
    $a->where('tags_old', null)->update(array('tags_migrated' => 1));
    $c->where('tags_old', null)->update(array('tags_migrated' => 1));
    $t->where('tags_old', null)->update(array('tags_migrated' => 1));
}
$done = true;
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:31,代码来源:0027.php


注:本文中的Content::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。