diff --git a/.env.example b/.env.example index ea0665b..eb4b91e 100644 --- a/.env.example +++ b/.env.example @@ -8,12 +8,12 @@ LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=laravel -DB_USERNAME=root -DB_PASSWORD= +DB_CONNECTION=pgsql +DB_HOST=pgsql +DB_PORT=5432 +DB_DATABASE=intern_project +DB_USERNAME=postgres +DB_PASSWORD=password BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index dbc4e4c..b0b6260 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -15,6 +15,10 @@ public function index(){ } //login module + /** + * Rename LoginFormValidator to LoginRequest + * + */ public function login(LoginFormValidator $request){ try{ if(auth()->guard('admin')->attempt($request->only(['username', 'password']))): @@ -22,6 +26,12 @@ public function login(LoginFormValidator $request){ else: return redirect()->back()->with('message', 'Invalid Credentials'); endif; + + /** + * + * if there is already return function then no need to write else part. + * + */ }catch(\Exception $e){ return redirect()->back()->with('message', $e->getMessage()); } @@ -31,6 +41,13 @@ public function login(LoginFormValidator $request){ //logout module public function logout(Request $request){ Auth::guard('admin')->logout(); + + /** + * remove Unnecesary codes + * + * $request->session()->invalidate(); + * $request->session()->regenerateToken(); + */ $request->session()->invalidate(); $request->session()->regenerateToken(); return redirect('/admin-login'); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 69644d1..c9526e1 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -23,6 +23,12 @@ public function index(Category $category) */ public function create(Category $category) { + + /** + * Alwyas try to paginate + * + * Write query in avariable instead of directly passing + */ return view('backend.modals.admin-add-category', ['datas' => $category->whereNull('parent_id') ->orWhereHas('parent', fn ($query) => $query->whereNull('parent_id')) ->get() @@ -30,6 +36,9 @@ public function create(Category $category) } /** + * Rename CategoryFormValidator to CategoryFormRequest + * + * * Store a newly created resource in storage. */ public function store(CategoryFormValidator $request) @@ -60,6 +69,13 @@ public function show(Category $category) public function edit(string $id) { try{ + + /** + * Always try to paginate instead of get(); + * rename datas to data + * + * + */ $editableData = Category::select('id', 'category_name','parent_id')->findOrFail($id); $datas = Category::whereNull('parent_id') ->orWhereHas('parent', fn ($query) => $query->whereNull('parent_id'))