{"action":"created","comment":{"url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/comments/56276084","id":56276084,"diff_hunk":"@@ -0,0 +1,197 @@\n+<?php\n+\n+namespace App\\Http\\Controllers;\n+\n+use Illuminate\\Http\\Request;\n+\n+use App\\Http\\Requests;\n+use App\\Http\\Controllers\\Controller;\n+use App\\Repositories\\Eloquent\\Repository;\n+use App\\Repositories\\Eloquent\\CategoryRepository as Category;\n+use App\\Http\\Requests\\AddCategoriesRequest;\n+use App\\Http\\Requests\\EditCategoriesRequest;\n+use File;\n+\n+class CategoriesController extends Controller\n+{\n+    private $category;\n+    \n+    public function __construct(Category $category) {\n+        $this->category = $category;\n+    }\n+    /**\n+     * Display a listing of the resource.\n+     *\n+     * @return \\Illuminate\\Http\\Response\n+     */\n+    public function index()\n+    {\n+        $category = $this->category->all();\n+\n+        return view(\"admin.categories.index\", [\n+            'category'      => $category,\n+            'page_title'    => 'Category'\n+        ]);\n+        \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+        $category = $this->category->all(['id','title']);\n+        return view(\"partials.admin.categories.popup_add_categories\", [\n+            'page_title'    => 'Category',\n+            'category'      => $category\n+        ]);\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(AddCategoriesRequest $request)\n+    {\n+        $result = [\n+            'error'     => 0,\n+            'message'   => '',\n+        ];\n+\n+        if(!isset($request->status)) {\n+            $status = 0;\n+        } else {\n+            $status = $request->status;\n+        }\n+\n+        $category = $this->category->create([\n+            'parent_id'     => $request->parent_id,\n+            'title'         => $request->title,\n+            'description'   => $request->description,\n+            'status'        => $status\n+        ]);\n+\n+        $destinationPath = 'media/categories/img/';\n+        $extension       = $request['image']->getClientOriginalExtension();\n+        $fileName        = $category->id . '_Categories.' . $extension;\n+\n+        $url_save = $destinationPath . $fileName;\n+\n+        $category->update([\n+            'image' => $url_save,\n+        ]);\n+\n+        if (!File::exists($destinationPath)) {\n+            mkdir($destinationPath, 0777, true);\n+        }\n+        $request['image']->move($destinationPath, $fileName);\n+\n+        if (!isset($category->id)) {\n+            $result['error']    = 1;\n+            $result['message']  = 'Add Categories false.';\n+        }\n+\n+        $result['message'] = 'Add Categories successfully.';\n+        return response()->json($result);\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+        //\n+        $list_category = $this->category->all(['id', 'title']);\n+        $category = $this->category->find($id);\n+        return view(\"partials.admin.categories.popup_edit_categories\", [\n+            'category' => $category,\n+            'list_category' => $list_category\n+        ]);\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(EditCategoriesRequest $request, $id)\n+    {\n+        //\n+        $result = [\n+            'error' => 0,\n+            'message' => '',\n+        ];\n+\n+        if(!isset($request->status)) {\n+            $status = 0;\n+        } else {\n+            $status = $request->status;\n+        }\n+\n+        $category = $this->category->find($id);\n+        $category->update([\n+            'parent_id'     => $request->parent_id,\n+            'title'         => $request->title,\n+            'description'   => $request->description,\n+            'status'        => $status\n+        ]);\n+\n+        if (isset($request->image)) {\n+\n+            $destinationPath = 'media/categories/img/';\n+            $extension       = $request['image']->getClientOriginalExtension();\n+            $fileName        = $category->id . '_Categories.' . $extension;\n+\n+            $url_save = $destinationPath . $fileName;\n+\n+            $category->update([\n+                'image' => $url_save,\n+            ]);\n+\n+            if (!File::exists($destinationPath)) {\n+                mkdir($destinationPath, 0777, true);\n+            }\n+            // File::delete( $destinationPath . $request['url_image']);\n+            $request['image']->move($destinationPath, $fileName);\n+        }\n+\n+        $result['message'] = 'Add Categories successfully.';\n+        return response()->json($result);\n+\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+        $category = $this->category->find($id);\n+        File::delete(\"media/categories/img/10_Categories.png\");\n+        $category->delete();\n+\n+        return redirect('/admin/category')->with('status', 'Delete Success!');","path":"app/Http/Controllers/CategoriesController.php","position":195,"original_position":195,"commit_id":"7346f51bdd71ae3a2f3706aa4415755ecbca499e","original_commit_id":"7346f51bdd71ae3a2f3706aa4415755ecbca499e","user":{"login":"hoangnh228","id":13269537,"avatar_url":"https://avatars.githubusercontent.com/u/13269537?v=3","gravatar_id":"","url":"https://api.github.com/users/hoangnh228","html_url":"https://github.com/hoangnh228","followers_url":"https://api.github.com/users/hoangnh228/followers","following_url":"https://api.github.com/users/hoangnh228/following{/other_user}","gists_url":"https://api.github.com/users/hoangnh228/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangnh228/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangnh228/subscriptions","organizations_url":"https://api.github.com/users/hoangnh228/orgs","repos_url":"https://api.github.com/users/hoangnh228/repos","events_url":"https://api.github.com/users/hoangnh228/events{/privacy}","received_events_url":"https://api.github.com/users/hoangnh228/received_events","type":"User","site_admin":false},"body":"Category delete successfully!","created_at":"2016-03-16T03:01:50Z","updated_at":"2016-03-16T03:01:50Z","html_url":"https://github.com/hoangnh228/laravel-shop/pull/2#discussion_r56276084","pull_request_url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/comments/56276084"},"html":{"href":"https://github.com/hoangnh228/laravel-shop/pull/2#discussion_r56276084"},"pull_request":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2","id":62880624,"html_url":"https://github.com/hoangnh228/laravel-shop/pull/2","diff_url":"https://github.com/hoangnh228/laravel-shop/pull/2.diff","patch_url":"https://github.com/hoangnh228/laravel-shop/pull/2.patch","issue_url":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/2","number":2,"state":"open","locked":false,"title":"Categories - CRUD","user":{"login":"nguyenducdev","id":15864129,"avatar_url":"https://avatars.githubusercontent.com/u/15864129?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenducdev","html_url":"https://github.com/nguyenducdev","followers_url":"https://api.github.com/users/nguyenducdev/followers","following_url":"https://api.github.com/users/nguyenducdev/following{/other_user}","gists_url":"https://api.github.com/users/nguyenducdev/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenducdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenducdev/subscriptions","organizations_url":"https://api.github.com/users/nguyenducdev/orgs","repos_url":"https://api.github.com/users/nguyenducdev/repos","events_url":"https://api.github.com/users/nguyenducdev/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenducdev/received_events","type":"User","site_admin":false},"body":"Categories - CRUD","created_at":"2016-03-15T10:05:53Z","updated_at":"2016-03-16T03:01:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87776e70f6fee5c273fe1c0d8af61d89ed7b6c59","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2/commits","review_comments_url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2/comments","review_comment_url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/2/comments","statuses_url":"https://api.github.com/repos/hoangnh228/laravel-shop/statuses/7346f51bdd71ae3a2f3706aa4415755ecbca499e","head":{"label":"nguyenducdev:p1-category","ref":"p1-category","sha":"7346f51bdd71ae3a2f3706aa4415755ecbca499e","user":{"login":"nguyenducdev","id":15864129,"avatar_url":"https://avatars.githubusercontent.com/u/15864129?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenducdev","html_url":"https://github.com/nguyenducdev","followers_url":"https://api.github.com/users/nguyenducdev/followers","following_url":"https://api.github.com/users/nguyenducdev/following{/other_user}","gists_url":"https://api.github.com/users/nguyenducdev/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenducdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenducdev/subscriptions","organizations_url":"https://api.github.com/users/nguyenducdev/orgs","repos_url":"https://api.github.com/users/nguyenducdev/repos","events_url":"https://api.github.com/users/nguyenducdev/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenducdev/received_events","type":"User","site_admin":false},"repo":{"id":53400793,"name":"laravel-shop","full_name":"nguyenducdev/laravel-shop","owner":{"login":"nguyenducdev","id":15864129,"avatar_url":"https://avatars.githubusercontent.com/u/15864129?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenducdev","html_url":"https://github.com/nguyenducdev","followers_url":"https://api.github.com/users/nguyenducdev/followers","following_url":"https://api.github.com/users/nguyenducdev/following{/other_user}","gists_url":"https://api.github.com/users/nguyenducdev/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenducdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenducdev/subscriptions","organizations_url":"https://api.github.com/users/nguyenducdev/orgs","repos_url":"https://api.github.com/users/nguyenducdev/repos","events_url":"https://api.github.com/users/nguyenducdev/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenducdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nguyenducdev/laravel-shop","description":"Shop base using Laravel 5","fork":true,"url":"https://api.github.com/repos/nguyenducdev/laravel-shop","forks_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/forks","keys_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/teams","hooks_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/hooks","issue_events_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/issues/events{/number}","events_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/events","assignees_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/assignees{/user}","branches_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/branches{/branch}","tags_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/tags","blobs_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/git/refs{/sha}","trees_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/statuses/{sha}","languages_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/languages","stargazers_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/stargazers","contributors_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/contributors","subscribers_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/subscribers","subscription_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/subscription","commits_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/commits{/sha}","git_commits_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/git/commits{/sha}","comments_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/comments{/number}","issue_comment_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/issues/comments{/number}","contents_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/contents/{+path}","compare_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/merges","archive_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/downloads","issues_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/issues{/number}","pulls_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/pulls{/number}","milestones_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/milestones{/number}","notifications_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/labels{/name}","releases_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/releases{/id}","deployments_url":"https://api.github.com/repos/nguyenducdev/laravel-shop/deployments","created_at":"2016-03-08T09:44:20Z","updated_at":"2016-03-08T09:44:22Z","pushed_at":"2016-03-15T10:04:08Z","git_url":"git://github.com/nguyenducdev/laravel-shop.git","ssh_url":"git@github.com:nguyenducdev/laravel-shop.git","clone_url":"https://github.com/nguyenducdev/laravel-shop.git","svn_url":"https://github.com/nguyenducdev/laravel-shop","homepage":null,"size":6508,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"hoangnh228:master","ref":"master","sha":"adab713578612c879fed786fdb9b7d96dcc06d05","user":{"login":"hoangnh228","id":13269537,"avatar_url":"https://avatars.githubusercontent.com/u/13269537?v=3","gravatar_id":"","url":"https://api.github.com/users/hoangnh228","html_url":"https://github.com/hoangnh228","followers_url":"https://api.github.com/users/hoangnh228/followers","following_url":"https://api.github.com/users/hoangnh228/following{/other_user}","gists_url":"https://api.github.com/users/hoangnh228/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangnh228/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangnh228/subscriptions","organizations_url":"https://api.github.com/users/hoangnh228/orgs","repos_url":"https://api.github.com/users/hoangnh228/repos","events_url":"https://api.github.com/users/hoangnh228/events{/privacy}","received_events_url":"https://api.github.com/users/hoangnh228/received_events","type":"User","site_admin":false},"repo":{"id":53378891,"name":"laravel-shop","full_name":"hoangnh228/laravel-shop","owner":{"login":"hoangnh228","id":13269537,"avatar_url":"https://avatars.githubusercontent.com/u/13269537?v=3","gravatar_id":"","url":"https://api.github.com/users/hoangnh228","html_url":"https://github.com/hoangnh228","followers_url":"https://api.github.com/users/hoangnh228/followers","following_url":"https://api.github.com/users/hoangnh228/following{/other_user}","gists_url":"https://api.github.com/users/hoangnh228/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangnh228/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangnh228/subscriptions","organizations_url":"https://api.github.com/users/hoangnh228/orgs","repos_url":"https://api.github.com/users/hoangnh228/repos","events_url":"https://api.github.com/users/hoangnh228/events{/privacy}","received_events_url":"https://api.github.com/users/hoangnh228/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hoangnh228/laravel-shop","description":"Shop base using Laravel 5","fork":false,"url":"https://api.github.com/repos/hoangnh228/laravel-shop","forks_url":"https://api.github.com/repos/hoangnh228/laravel-shop/forks","keys_url":"https://api.github.com/repos/hoangnh228/laravel-shop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoangnh228/laravel-shop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoangnh228/laravel-shop/teams","hooks_url":"https://api.github.com/repos/hoangnh228/laravel-shop/hooks","issue_events_url":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/events{/number}","events_url":"https://api.github.com/repos/hoangnh228/laravel-shop/events","assignees_url":"https://api.github.com/repos/hoangnh228/laravel-shop/assignees{/user}","branches_url":"https://api.github.com/repos/hoangnh228/laravel-shop/branches{/branch}","tags_url":"https://api.github.com/repos/hoangnh228/laravel-shop/tags","blobs_url":"https://api.github.com/repos/hoangnh228/laravel-shop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoangnh228/laravel-shop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoangnh228/laravel-shop/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoangnh228/laravel-shop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoangnh228/laravel-shop/statuses/{sha}","languages_url":"https://api.github.com/repos/hoangnh228/laravel-shop/languages","stargazers_url":"https://api.github.com/repos/hoangnh228/laravel-shop/stargazers","contributors_url":"https://api.github.com/repos/hoangnh228/laravel-shop/contributors","subscribers_url":"https://api.github.com/repos/hoangnh228/laravel-shop/subscribers","subscription_url":"https://api.github.com/repos/hoangnh228/laravel-shop/subscription","commits_url":"https://api.github.com/repos/hoangnh228/laravel-shop/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoangnh228/laravel-shop/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoangnh228/laravel-shop/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoangnh228/laravel-shop/contents/{+path}","compare_url":"https://api.github.com/repos/hoangnh228/laravel-shop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoangnh228/laravel-shop/merges","archive_url":"https://api.github.com/repos/hoangnh228/laravel-shop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoangnh228/laravel-shop/downloads","issues_url":"https://api.github.com/repos/hoangnh228/laravel-shop/issues{/number}","pulls_url":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls{/number}","milestones_url":"https://api.github.com/repos/hoangnh228/laravel-shop/milestones{/number}","notifications_url":"https://api.github.com/repos/hoangnh228/laravel-shop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoangnh228/laravel-shop/labels{/name}","releases_url":"https://api.github.com/repos/hoangnh228/laravel-shop/releases{/id}","deployments_url":"https://api.github.com/repos/hoangnh228/laravel-shop/deployments","created_at":"2016-03-08T03:20:18Z","updated_at":"2016-03-08T03:22:11Z","pushed_at":"2016-03-15T10:05:53Z","git_url":"git://github.com/hoangnh228/laravel-shop.git","ssh_url":"git@github.com:hoangnh228/laravel-shop.git","clone_url":"https://github.com/hoangnh228/laravel-shop.git","svn_url":"https://github.com/hoangnh228/laravel-shop","homepage":null,"size":6501,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2"},"html":{"href":"https://github.com/hoangnh228/laravel-shop/pull/2"},"issue":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/2"},"comments":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/hoangnh228/laravel-shop/statuses/7346f51bdd71ae3a2f3706aa4415755ecbca499e"}}}}