标签:fan minutes ext lis links view set ping option
归类用法
查
$links = Links::all();
$configs = Options::all(array(‘id‘, ‘option_name‘, ‘option_value‘));
$category = Categorys::where(‘category_flag‘, $flag)->first();
$post = Posts::where(‘flag‘, $flag)->first();
$posts = Posts::OfType(‘post‘)->orderBy(‘id‘, ‘desc‘)->take(15)->get();
$posts = $category->posts()->paginate(15);//关系,这个分类的文章15个,$this->belongsTo(‘Categorys::class’) ,$this->belongsToMany(‘Tags::class’);
$posts = Posts::orderBy(‘id‘, ‘desc‘)->paginate(15);
Posts::increment(‘views‘, 1);
$post->categories;
$post->tags;
$post->user;
$categorys = Categorys::firstOrCreate([‘category_name‘ => $category]);
特殊函数
$key = hash(‘sha256‘, $flag);
Cache
$post = cache($key);
cache([$key => $post], $this->expiresAt);
Cache::has(‘rss-feed‘)
Cache::add(‘rss-feed‘, $rss, $expiresAt);
return Cache::get(‘rss-feed‘);
}
时间函数
{{$post->created_at->format(‘c‘)}
$this->expiresAt = Carbon::now()->addMinutes(1440);
$expiresAt = Carbon::createFromTimestamp(strtotime($options->updated_at))->addMinutes(10);//获取距离当前时间函数
$ts = Carbon::yesterday()->timestamp;
//人性化显示时间
echo Carbon::createFromTimestamp($ts)->diffForHumans();
上面的打印结果是1天前
Carbon::createFromTimestamp(strtotime($date))->addDays(30);
carbon->toDateString() <= date(‘Y-m-d‘)
跳转函数
<a href="{{ route(‘tags‘,[$tag->tags_flag]) }}"
->url(url(‘/‘)) //里面放的是路由值
->url(url(‘/post/‘ . $post->flag))
$data[‘link‘] = route(‘posts‘, [$post->wp_slug]);//名字
响应
return response($rss)->header(‘Content-type‘, ‘text/xml; charset=UTF-8‘);
return response($map)->header(‘Content-type‘, ‘text/xml‘);
return response()->json($lists);
2 build做方法名称不错
buildRssData
public function authenticate($email, $password)//认证
标签:fan minutes ext lis links view set ping option
原文地址:http://www.cnblogs.com/keiweila/p/7841725.html