{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_131/pulls/comments/66914267","id":66914267,"diff_hunk":"@@ -0,0 +1,128 @@\n+<?php\n+\n+namespace App\\Http\\Controllers;\n+\n+use App\\Repositories\\Word\\WordRepositoryInterface;\n+use App\\Repositories\\Category\\CategoryRepositoryInterface;\n+use Illuminate\\Http\\Request;\n+\n+use App\\Http\\Requests;\n+\n+class WordAdminController extends Controller\n+{\n+\n+    private $wordRepository;\n+    private $categoryRepository;\n+\n+    public function __construct(WordRepositoryInterface $wordRepository, CategoryRepositoryInterface $categoryRepository)\n+    {\n+        $this->wordRepository = $wordRepository;\n+        $this->categoryRepository = $categoryRepository;\n+    }\n+\n+    /**\n+     * Display a listing of the resource.\n+     *\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function index()\n+    {\n+        $this->viewData = $this->wordRepository->index('words');\n+        return view('layout.grid', $this->viewData);\n+    }\n+\n+    /**\n+     * Show the form for creating a new resource.\n+     *\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function create()\n+    {\n+        $categories = $this->categoryRepository->all();\n+        foreach ($categories as $key => $category) {\n+            $this->viewData['categories'][$category['id']] = $category['name'];\n+        }\n+        return view('word.create', $this->viewData);\n+    }\n+\n+    /**\n+     * Store a newly created resource in storage.\n+     *\n+     * @param  \\Illuminate\\Http\\Request $request\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function store(Request $request)\n+    {\n+        $data = $this->wordRepository->store($request->only('content', 'category_id'));\n+        if (isset($data['errors'])) {\n+            return redirect()->route('admin.words.create')->with('error', $data['errors']['message'])->withInput();\n+        }\n+        return redirect()->route('admin.words.index')->with('success', trans('general/message.create_successfully'));\n+    }\n+\n+    /**\n+     * Display the specified resource.\n+     *\n+     * @param  int $id\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function show($id)\n+    {\n+        //\n+    }\n+\n+    /**\n+     * Show the form for editing the specified resource.\n+     *\n+     * @param  int $id\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function edit($id)\n+    {\n+        $word = $this->wordRepository->show($id);\n+        if (isset($word['errors'])) {\n+            return redirect()->route('admin.words.index')->with('error', $word['errors']['message']);\n+        }\n+        $categories = $this->categoryRepository->all();\n+        foreach ($categories as $key => $category) {\n+            $this->viewData['categories'][$category['id']] = $category['name'];\n+        }\n+        $this->viewData['word'] = $word;\n+        return view('word.edit', $this->viewData);\n+    }\n+\n+    /**\n+     * Update the specified resource in storage.\n+     *\n+     * @param  \\Illuminate\\Http\\Request $request\n+     * @param  int $id\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function update(Request $request, $id)\n+    {\n+        $data = $this->wordRepository->update($request->only('content', 'category_id'), $id);\n+        if (isset($data['errors']))\n+            return redirect()->route('admin.words.edit', ['id' => $id])->with('error', $data['errors']['message']);\n+        return redirect()->route('admin.words.index')->with('success', trans('general/message.update_successfully'));\n+    }\n+\n+    /**\n+     * Remove the specified resource from storage.\n+     *\n+     * @param  int $id\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function destroy($id)\n+    {\n+        if(request()->ajax()){\n+            $id = request()->get('ids');\n+        }\n+        $data = $this->wordRepository->delete($id);\n+        if (isset($data['errors'])) {\n+            session()->flash('error', $data['errors']['message']);\n+            return false;\n+        }\n+        session()->flash('success', trans('general/message.delete_successfully'));\n+        return $data;","path":"app/Http/Controllers/WordAdminController.php","position":126,"original_position":126,"commit_id":"63128f2839fe399f0c7fbd76d3d09c44c0437030","original_commit_id":"63128f2839fe399f0c7fbd76d3d09c44c0437030","user":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"body":"em không hiểu, sao lại dùng response->json làm gì vậy.","created_at":"2016-06-14T06:23:31Z","updated_at":"2016-06-14T06:23:31Z","html_url":"https://github.com/framgia/fels_131/pull/10#discussion_r66914267","pull_request_url":"https://api.github.com/repos/framgia/fels_131/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/comments/66914267"},"html":{"href":"https://github.com/framgia/fels_131/pull/10#discussion_r66914267"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_131/pulls/10","id":73684838,"html_url":"https://github.com/framgia/fels_131/pull/10","diff_url":"https://github.com/framgia/fels_131/pull/10.diff","patch_url":"https://github.com/framgia/fels_131/pull/10.patch","issue_url":"https://api.github.com/repos/framgia/fels_131/issues/10","number":10,"state":"open","locked":false,"title":"Create word management","user":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-14T06:09:08Z","updated_at":"2016-06-14T06:23:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14d123a223966b027e2bf574a40457a81b2b76b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_131/pulls/10/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_131/pulls/10/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_131/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_131/issues/10/comments","statuses_url":"https://api.github.com/repos/framgia/fels_131/statuses/63128f2839fe399f0c7fbd76d3d09c44c0437030","head":{"label":"luongs3:develop","ref":"develop","sha":"63128f2839fe399f0c7fbd76d3d09c44c0437030","user":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"repo":{"id":58017414,"name":"fels_131","full_name":"luongs3/fels_131","owner":{"login":"luongs3","id":12150725,"avatar_url":"https://avatars.githubusercontent.com/u/12150725?v=3","gravatar_id":"","url":"https://api.github.com/users/luongs3","html_url":"https://github.com/luongs3","followers_url":"https://api.github.com/users/luongs3/followers","following_url":"https://api.github.com/users/luongs3/following{/other_user}","gists_url":"https://api.github.com/users/luongs3/gists{/gist_id}","starred_url":"https://api.github.com/users/luongs3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luongs3/subscriptions","organizations_url":"https://api.github.com/users/luongs3/orgs","repos_url":"https://api.github.com/users/luongs3/repos","events_url":"https://api.github.com/users/luongs3/events{/privacy}","received_events_url":"https://api.github.com/users/luongs3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luongs3/fels_131","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/luongs3/fels_131","forks_url":"https://api.github.com/repos/luongs3/fels_131/forks","keys_url":"https://api.github.com/repos/luongs3/fels_131/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luongs3/fels_131/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luongs3/fels_131/teams","hooks_url":"https://api.github.com/repos/luongs3/fels_131/hooks","issue_events_url":"https://api.github.com/repos/luongs3/fels_131/issues/events{/number}","events_url":"https://api.github.com/repos/luongs3/fels_131/events","assignees_url":"https://api.github.com/repos/luongs3/fels_131/assignees{/user}","branches_url":"https://api.github.com/repos/luongs3/fels_131/branches{/branch}","tags_url":"https://api.github.com/repos/luongs3/fels_131/tags","blobs_url":"https://api.github.com/repos/luongs3/fels_131/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luongs3/fels_131/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luongs3/fels_131/git/refs{/sha}","trees_url":"https://api.github.com/repos/luongs3/fels_131/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luongs3/fels_131/statuses/{sha}","languages_url":"https://api.github.com/repos/luongs3/fels_131/languages","stargazers_url":"https://api.github.com/repos/luongs3/fels_131/stargazers","contributors_url":"https://api.github.com/repos/luongs3/fels_131/contributors","subscribers_url":"https://api.github.com/repos/luongs3/fels_131/subscribers","subscription_url":"https://api.github.com/repos/luongs3/fels_131/subscription","commits_url":"https://api.github.com/repos/luongs3/fels_131/commits{/sha}","git_commits_url":"https://api.github.com/repos/luongs3/fels_131/git/commits{/sha}","comments_url":"https://api.github.com/repos/luongs3/fels_131/comments{/number}","issue_comment_url":"https://api.github.com/repos/luongs3/fels_131/issues/comments{/number}","contents_url":"https://api.github.com/repos/luongs3/fels_131/contents/{+path}","compare_url":"https://api.github.com/repos/luongs3/fels_131/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luongs3/fels_131/merges","archive_url":"https://api.github.com/repos/luongs3/fels_131/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luongs3/fels_131/downloads","issues_url":"https://api.github.com/repos/luongs3/fels_131/issues{/number}","pulls_url":"https://api.github.com/repos/luongs3/fels_131/pulls{/number}","milestones_url":"https://api.github.com/repos/luongs3/fels_131/milestones{/number}","notifications_url":"https://api.github.com/repos/luongs3/fels_131/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luongs3/fels_131/labels{/name}","releases_url":"https://api.github.com/repos/luongs3/fels_131/releases{/id}","deployments_url":"https://api.github.com/repos/luongs3/fels_131/deployments","created_at":"2016-05-04T02:40:59Z","updated_at":"2016-05-04T02:32:42Z","pushed_at":"2016-06-14T06:08:32Z","git_url":"git://github.com/luongs3/fels_131.git","ssh_url":"git@github.com:luongs3/fels_131.git","clone_url":"https://github.com/luongs3/fels_131.git","svn_url":"https://github.com/luongs3/fels_131","homepage":null,"size":142,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"5c9a8ec19e1054ba27f00f6e1cc43139cb6191f7","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":58016936,"name":"fels_131","full_name":"framgia/fels_131","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/fels_131","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_131","forks_url":"https://api.github.com/repos/framgia/fels_131/forks","keys_url":"https://api.github.com/repos/framgia/fels_131/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_131/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_131/teams","hooks_url":"https://api.github.com/repos/framgia/fels_131/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_131/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_131/events","assignees_url":"https://api.github.com/repos/framgia/fels_131/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_131/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_131/tags","blobs_url":"https://api.github.com/repos/framgia/fels_131/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_131/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_131/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_131/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_131/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_131/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_131/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_131/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_131/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_131/subscription","commits_url":"https://api.github.com/repos/framgia/fels_131/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_131/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_131/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_131/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_131/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_131/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_131/merges","archive_url":"https://api.github.com/repos/framgia/fels_131/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_131/downloads","issues_url":"https://api.github.com/repos/framgia/fels_131/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_131/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_131/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_131/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_131/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_131/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/fels_131/deployments","created_at":"2016-05-04T02:32:42Z","updated_at":"2016-05-04T02:32:42Z","pushed_at":"2016-06-14T06:09:08Z","git_url":"git://github.com/framgia/fels_131.git","ssh_url":"git@github.com:framgia/fels_131.git","clone_url":"https://github.com/framgia/fels_131.git","svn_url":"https://github.com/framgia/fels_131","homepage":null,"size":138,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/10"},"html":{"href":"https://github.com/framgia/fels_131/pull/10"},"issue":{"href":"https://api.github.com/repos/framgia/fels_131/issues/10"},"comments":{"href":"https://api.github.com/repos/framgia/fels_131/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_131/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_131/statuses/63128f2839fe399f0c7fbd76d3d09c44c0437030"}}}}
{"actor":{"display_login":"luongs3"}}