Exemplo n.º 1
0
 public function isCompleted($requireFullCompletion = false, $user = false)
 {
     if (Auth::check() || $user !== false) {
         $archive = Archive::where(['test_id' => $this->id, 'user_id' => $user === false ? Auth::user()->id : $user->id])->first();
         if ($archive) {
             $data = json_decode($archive->data, true);
             return $data['all_correct'] || $archive->replied_to || $archive->discarded == \App\Archive::FULLY_DISCARDED || !$requireFullCompletion && $data['num_correct'] >= $data['total'] * 0.5;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * 更新文章
  *
  * @param PostUpdateRequest $request 文章更新表单
  * @param int $id 文章id
  */
 public function update(PostUpdateRequest $request, $id)
 {
     $post = Post::findOrFail($id);
     $check = $post->archive;
     $post->fill($request->postFillData());
     $post->save();
     if ($request->archive != $check) {
         $counts = Archive::where('name', '=', $check)->first()->counts;
         $archive = Archive::where('name', '=', $check)->update(['counts' => $counts - 1]);
         $counts = Archive::where('name', '=', $request->archive)->first()->counts;
         $archive = Archive::where('name', '=', $request->archive)->update(['counts' => $counts + 1]);
     }
     return redirect()->route('admin.post.index')->withSuccess('Post saved.');
 }
Exemplo n.º 3
0
 public static function make()
 {
     $date = Carbon::now()->toDateTimeString();
     $sitemap = App::make("sitemap");
     $sitemap->add(route('index'), $date, "1.0", "daily");
     $sitemap->add(route('sharpen'), $date, "0.9", "daily");
     $sitemap->add(route('anecdote'), $date, "0.9", "daily");
     $sitemap->add(route('mind'), $date, "0.9", "daily");
     $archives = Archive::where("published", "=", 1)->get();
     foreach ($archives as $archive) {
         $sitemap->add(route('archive', ['id' => $archive->id]), $archive->updated_at, "0.8", "daily");
     }
     $sitemap->store('xml', 'sitemap');
 }
Exemplo n.º 4
0
 protected function getCategoryView($category)
 {
     $archives = Archive::where('category', '=', $category)->where("published", "=", 1)->orderBy("created_at", "desc")->paginate(6);
     $this->filterList($archives);
     $data = ['pageName' => $category, 'category' => $category, 'archives' => $archives];
     $this->dataFilter($data);
     return view('category', $data);
 }