本文整理汇总了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');
}
示例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]);
}
示例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);
}
示例4: factory
public static function factory($id = null)
{
$instance = new Content();
if (!empty($id)) {
$instance->where('id', $id)->get();
}
return $instance;
}
示例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>');
}
}
示例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);
}
示例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;
}
示例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.');
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;