/**
  * Display a listing of the resource with its problems connected;
  *
  * @return \Illuminate\Http\Response
  */
 public function problems($id)
 {
     $tag = Tag::findOrFail($id);
     $tags = TagService::getTagWithProblem($tag->id);
     $title = '문제 목록 - ' . $tag->name . ' - ' . $tags->currentPage() . ' 페이지';
     $resultAccCode = Result::acceptCode;
     return view('tags.problems', compact('tag', 'tags', 'title', 'resultAccCode'));
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @return void
  */
 public function boot()
 {
     parent::boot();
     Route::bind('article', function ($slug) {
         if (!Auth::user()) {
             return Article::published()->slug($slug)->first();
         }
         return Article::where('slug', $slug)->first() ?: Article::findOrFail((int) $slug);
     });
     Route::bind('tag', function ($slug) {
         if (!Auth::user()) {
             return Tag::slug($slug)->first();
         }
         return Tag::where('slug', $slug)->first() ?: Tag::findOrFail((int) $slug);
     });
     Route::bind('page', function ($id) {
         return Page::find($id);
     });
 }
Exemple #3
0
 /**
  * Get tag name by id.
  *
  * @param  int  $tag_id
  * @return string
  */
 public function getTagById($tag_id)
 {
     return $this->tag->findOrFail($tag_id)->tag;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $tag->delete();
     return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
 }
Exemple #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $data = Tag::findOrFail($id);
     return view('admin.tag.edit', ['data' => $data]);
 }
 public function getById($id)
 {
     $tag = Tag::findOrFail($id);
     return $tag;
 }
Exemple #7
0
 /**
  * 해당 태그를 가지고 있는 문제 목록을 카운트 순으로 가져오기
  *
  * @param int   $tag_id
  * @return paginate of Tag with problem
  */
 public function getTagWithProblem($tag_id)
 {
     if (Tag::findOrFail($tag_id)->status != Tag::openCode) {
         return abort(404);
     }
     return $this->service->getTagWithProblem($tag_id);
 }