本文整理汇总了PHP中app\Article::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::select方法的具体用法?PHP Article::select怎么用?PHP Article::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::select方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('eloquent.saving*', function ($model) {
if ($model instanceof Article) {
$articles = Article::select('slug')->get();
$slug = str_slug($model->title);
$i = 0;
do {
$flag = false;
foreach ($articles as $article) {
if ($article->slug == $slug) {
$flag = true;
$slug .= "-" . $i;
++$i;
}
}
} while ($flag);
$model->slug = $slug;
} else {
if ($model instanceof Member) {
} else {
if ($model instanceof Command) {
}
}
}
});
}
示例2: scopeSearch
/**
* Display the home page.
*
* @param Request $requests
*
*/
public function scopeSearch(Request $requests)
{
$keyword = $requests->get('q');
$results = null;
if (isset($keyword) && trim($keyword) != "") {
$results = Article::select('id', 'title', 'intro', 'page_image')->where('title', 'LIKE', '%' . $keyword . '%')->where('is_checked', true)->published()->paginate(10);
}
return view('front.search')->with('articles', $results);
}
示例3: excelArticles
/**
* Exporta el Listado de todos los articulos en formato Excel
*/
public function excelArticles()
{
Excel::create('Maestro de Artículos', function ($excel) {
$excel->sheet('Articulos', function ($sheet) {
$articles = Article::select('product_code', 'name', 'active', 'barcode')->orderBy('name')->get();
$sheet->fromArray($articles);
});
})->export('xlsx');
}
示例4: getAjaxTags
/**
* get tags ajax
*/
public function getAjaxTags(Request $request)
{
$tags = Article::select('meta_key')->where('meta_key', 'LIKE', '%' . $request->input('text') . '%')->take(20)->get();
$results = array();
$output = '<ul>';
if (count($tags) > 0) {
foreach ($tags as $tag) {
$t = explode(', ', $tag->meta_key);
$result = preg_grep('~' . $request->input('text') . '~', $t);
$result = reset($result);
if (!empty($result)) {
$results[] = $result;
}
}
if (count($results) > 0) {
foreach (array_unique($results) as $res) {
$output .= '<li data-name="' . $res . '">' . $res . '</li>';
}
}
} else {
return 0;
}
$output .= '</ul>';
return $output;
}
示例5: datas
/**
* article datas.
*
* @return \Illuminate\Http\Response
*/
public function datas()
{
return Datatables::of(Article::select('*'))->make(true);
}
示例6: showSerialsList
public function showSerialsList(Article $article, $slug)
{
$catName = Cat::select('name')->where('slug', $slug)->take(1)->get();
$movies = $article->select('title', 'img', 'head', 'body', 'slug')->bycatslug($slug)->language()->published()->latest()->take(get_setting('pagination_num'))->get();
return view('components.lists.serials', compact('movies', 'catName'));
}
示例7: home
public function home(Article $article)
{
$articles = $article->select('title')->get();
return view('home')->with('articles', $articles);
}
示例8: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$page = Article::findOrFail($id);
$this->translate_slug = $page->translate_slug;
$tr = Article::select('lang')->where('lang', '!=', $page->lang)->where(function ($query) {
return $query->where('slug', '=', $this->translate_slug)->orWhere('translate_slug', '=', $this->translate_slug);
})->groupBy('id')->get()->toArray();
$translates = array_pluck($tr, 'lang');
return view('admin.pages.edit', compact('page', 'translates'));
}
示例9: similars
public function similars($limit = 4)
{
return Article::select('id', 'title', 'slug', 'image_src')->where(['category_id' => $this->category_id, 'state' => 1])->where('id', '<>', $this->id)->orderByRaw("RANDOM()")->take($limit)->get();
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$pages = Article::select('id', 'title', 'lang')->latest()->maincat([1])->paginate(get_setting('pagination_num'));
return view('admin.pages.index', compact('pages'));
}
示例11: newsAuthor
public function newsAuthor($author)
{
$article = new Article();
$items = Article::select('id', 'body', 'title', 'head', 'published_at', 'slug', 'author', 'translate_slug', 'img', 'lang')->where('author', $author)->published()->getcat(55)->language()->latest()->take(get_setting('pagination_num'))->get();
$count = Article::where('author', $author)->published()->getcat(55)->language()->count();
return view('theme.pages.view.author', compact('items', 'article', 'count', 'author'));
}
示例12: pageWidget
function pageWidget($slug, $more = false, $min, $tags = array(), $title = true)
{
global $registry;
$output = '';
$registry['slug'] = $slug;
//Cache::pull($registry['slug']);
$entry = Cache::remember($registry['slug'], $min, function () {
global $registry;
return \App\Article::select('slug', 'title', 'body')->where('slug', $registry['slug'])->first();
});
if (count($entry) > 0) {
if ($title == true) {
$output .= '<div class="rub-title-gray"><a href="/' . $slug . '"><div><h3>' . $entry->title . '</h3></div></a></div>';
}
if (count($tags) > 0) {
$explode = explode('<!-- pagebreak -->', $entry->body);
if (count($explode) > 0) {
foreach ($tags as $key => $i) {
$output .= strip_tags($explode[$key]) . '<br>';
}
}
} else {
$output .= $entry->body;
}
if ($more == true) {
$output .= ' <a href="/' . $slug . '"><b>' . trans('all.fully') . '...</b></a>';
}
}
return $output;
}
示例13: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$articleId = $this->route('article');
$isChecked = Article::select('is_checked')->where('id', $articleId)->first();
return $isChecked->is_checked !== 1;
}