-
Notifications
You must be signed in to change notification settings - Fork 0
Feat:user controller created and route name added for profile #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
fa98a44
a68746e
06ad27e
1165824
a85b9be
c801c9d
40cf8c9
fad8963
99e5df2
af183bc
08dab68
c4418d3
c50a242
c577312
462846d
5ba5d27
5a2f3d9
e78e8b5
0178b15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "folders": [ | ||
| { | ||
| "path": "." | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Http\Requests\ProfileRequest; | ||
| use App\Services\UserService; | ||
| use Illuminate\Http\Request; | ||
| use App\Models\User; | ||
|
|
||
| class AdminController extends Controller | ||
| { | ||
| public function __construct() | ||
| { | ||
| $this->middleware('auth'); | ||
| } | ||
| /** | ||
| * Display a listing of the resource. | ||
| * | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function index() | ||
| { | ||
| $users = User::paginate(User::PAGINATE); | ||
|
|
||
| return view('admin.user.list', compact('users')); | ||
| } | ||
|
|
||
| /** | ||
| * Show the form for creating a new resource. | ||
| * | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function ban(User $user) | ||
| { | ||
|
|
||
| if ($user->is_banned) { | ||
| $user->is_banned = 0; | ||
| } else { | ||
| $user->is_banned = 1; | ||
| } | ||
| $user->update(); | ||
|
|
||
| return redirect()->back()->with('success', 'User Status Changed'); | ||
| } | ||
|
|
||
| public function delete(User $user) | ||
| { | ||
| $user->delete(); | ||
| return redirect()->back()->with('success', 'User Deleted'); | ||
| } | ||
| public function create() | ||
| { | ||
| return view('admin.user.add'); | ||
| } | ||
|
|
||
| /** | ||
| * Store a newly created resource in storage. | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function store(ProfileRequest $request, UserService $action) | ||
| { | ||
| $action->storeUser($request); | ||
| return redirect()->back()->with('success', 'Librarian Added'); | ||
| } | ||
|
|
||
| /** | ||
| * Display the specified resource. | ||
| * | ||
| * @param int $id | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function show($id) | ||
| { | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * Show the form for editing the specified resource. | ||
| * | ||
| * @param int $id | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function edit($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) | ||
| { | ||
| // | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Http\Requests\AuthorRequest; | ||
| use App\Models\Author; | ||
| use App\Services\AuthorService; | ||
| use Illuminate\Http\Request; | ||
|
|
||
| class AuthorController extends Controller | ||
| { | ||
| /** | ||
| * Display a listing of the resource. | ||
| * | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function index() | ||
| { | ||
| $authors = Author::paginate(Author::PAGINATE); | ||
| return view('admin.author.list', compact('authors')); | ||
| } | ||
|
|
||
| /** | ||
| * Show the form for creating a new resource. | ||
| * | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function create() | ||
| { | ||
| return view('admin.author.add'); | ||
| } | ||
|
|
||
| /** | ||
| * Store a newly created resource in storage. | ||
| * | ||
| * @param AuthorRequest $request | ||
| * @param AuthorService $action | ||
| * @return void | ||
| */ | ||
| public function store(AuthorRequest $request, AuthorService $action) | ||
| { | ||
| $action->storeAuthor($request); | ||
| return redirect()->back()->with('success', 'Author Added'); | ||
| } | ||
|
|
||
| /** | ||
| * Display the specified resource. | ||
| * | ||
| * @param int $id | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function show($id) | ||
| { | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * Show the form for editing the specified resource. | ||
| * | ||
| * @param Author $author | ||
| * @return \Illuminate\Http\Response | ||
| */ | ||
| public function edit(Author $author) | ||
| { | ||
| return view('admin.author.edit', compact('author')); | ||
| } | ||
|
|
||
| /** | ||
| * 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(Author $author) | ||
| { | ||
| $author->delete(); | ||
| return redirect()->back()->with('success', 'Author Deleted'); | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Http\Requests\ProfileRequest; | ||
| use App\Models\User; | ||
| use App\Services\UserService; | ||
|
|
||
| class UserController extends Controller | ||
| { | ||
| public function __construct() | ||
| { | ||
| $this->middleware('auth'); | ||
| } | ||
|
me-shaon marked this conversation as resolved.
|
||
|
|
||
| public function profile(User $user) | ||
| { | ||
| return view('profile', compact('user')); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an empty line after the method.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| public function dashboard() | ||
| { | ||
| return view('user.dashboard'); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an empty line after the method.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've missed this. |
||
|
|
||
| public function profileUpdate(ProfileRequest $request, UserService $action) | ||
| { | ||
| $profile = $action->getUser($request->id); | ||
| $action->updateUser($request, $profile); | ||
| return redirect()->back()->with('success', 'Profile updated'); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Requests; | ||
|
|
||
| use Illuminate\Foundation\Http\FormRequest; | ||
|
|
||
| class AuthorRequest extends FormRequest | ||
| { | ||
| /** | ||
| * Determine if the user is authorized to make this request. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function authorize() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Get the validation rules that apply to the request. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function rules() | ||
| { | ||
| return [ | ||
| 'name' => 'required', | ||
| 'description' => 'required' | ||
| ]; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.