-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8826ebd
commit e2e11bb
Showing
26 changed files
with
5,149 additions
and
835 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
|
||
class Category extends Model | ||
{ | ||
// | ||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class AdminController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
dd(Auth::check()); | ||
|
||
//first check if you are loggedin and admin user ... | ||
|
||
if(!Auth::check() && $request->path() != 'login'){ | ||
return redirect('/login'); | ||
} | ||
if(!Auth::check() && $request->path() == 'login' ){ | ||
return view('adminmaster'); | ||
} | ||
// you are already logged in... so check for if you are an admin user.. | ||
$user = Auth::user(); | ||
if($user->userType =='user'){ | ||
return redirect('/login'); | ||
} | ||
if($request->path() == 'login'){ | ||
return redirect('/'); | ||
} | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show($id) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, $id) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Category; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
class CategoryController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return Category::orderBy('id', 'desc')->get(); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
$this->validate($request, [ | ||
'categoryName' => 'required', | ||
'iconImage' => 'required', | ||
]); | ||
return Category::create([ | ||
'categoryName'=>$request->categoryName, | ||
'iconImage'=>$request->iconImage, | ||
]); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show($id) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, $id) | ||
{ | ||
$category = Category::find($id); | ||
$this->validate($request, [ | ||
'categoryName' => 'required', | ||
'iconImage' => 'required', | ||
]); | ||
|
||
$category->categoryName = $request->categoryName; | ||
$category->iconImage = $request->iconImage; | ||
$category->save(); | ||
} | ||
|
||
/* Category Image upload functionality */ | ||
|
||
public function categoryImage(Request $request){ | ||
$request->validate([ | ||
'file'=>'required|mimes:jpeg,png,jpg,bmp,webp,gif', | ||
]); | ||
$picname =time().'.'.$request->file->getClientOriginalExtension(); | ||
$request->file->move(public_path('admin/images/category'), $picname); | ||
return $picname; | ||
} | ||
|
||
|
||
/* Delete Category Image */ | ||
|
||
public function deleteCategoryImage(Request $request){ | ||
$filename = $request->imageName; | ||
$filepath = public_path().$filename; | ||
if(file_exists($filepath)){ | ||
@unlink($filepath); | ||
} | ||
return $filepath; | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param int $id | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
$category = Category::findOrFail($id); | ||
$category->delete(); | ||
$filename = $category->imageName; | ||
$filepath = public_path().'/admin/images/category/'.$filename; | ||
if(file_exists($filepath)){ | ||
@unlink($filepath); | ||
} | ||
return $filepath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Validation\ValidationException; | ||
|
||
class LoginController extends Controller | ||
{ | ||
public function adminlogin(Request $request){ | ||
// validate request | ||
$this->validate($request, [ | ||
'email' => 'bail|required|email', | ||
'password' => 'bail|required|min:6', | ||
]); | ||
if(Auth::attempt(['email' => $request->email, 'password' => $request->password])){ | ||
$user = Auth::user(); | ||
if($user->userType == 'user'){ | ||
Auth::logout(); | ||
return response()->json([ | ||
'msg' => 'You do Not have Access', | ||
], 401); | ||
} | ||
|
||
return response()->json([ | ||
'msg' => 'You are logged in', | ||
'user' => $user | ||
]); | ||
|
||
}else{ | ||
return response()->json([ | ||
'msg' => 'Incorrect login details', | ||
], 401); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.