forked from pilpod/nuwe-challenge-team
-
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.
Merge branch 'feature/database' into pre-deploy2
- Loading branch information
Showing
29 changed files
with
725 additions
and
42 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
|
||
class AdminController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
$this->middleware('admin'); | ||
} | ||
|
||
public function index() | ||
{ | ||
$users = User::all(); | ||
|
||
return view('admin-dashboard', ['users' => $users]); | ||
} | ||
|
||
public function edit($id) | ||
{ | ||
$user = User::find($id); | ||
return view('edit-user', ['user' => $user]); | ||
} | ||
|
||
public function show($id) | ||
{ | ||
$user = User::find($id); | ||
return view('show-user', ['user' => $user]); | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
$user = User::find($id); | ||
|
||
$user->name = $request->name; | ||
$user->isAdmin = $request->isAdmin; | ||
|
||
$user->save(); | ||
|
||
return view('show-user', ['user' => $user]); | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
|
||
class UserController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
|
||
} | ||
|
||
} |
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,85 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\WorkExperience; | ||
use Illuminate\Http\Request; | ||
|
||
class WorkExperienceController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* 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 \App\Models\WorkExperience $workExperience | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show(WorkExperience $workExperience) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \App\Models\WorkExperience $workExperience | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit(WorkExperience $workExperience) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\WorkExperience $workExperience | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, WorkExperience $workExperience) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \App\Models\WorkExperience $workExperience | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(WorkExperience $workExperience) | ||
{ | ||
// | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class AdminMiddleware | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure $next | ||
* @return mixed | ||
*/ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
if(Auth::check() && Auth::user()->isAdmin==true) { | ||
return $next($request); | ||
} | ||
|
||
return redirect('login'); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class WorkExperience extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'position', | ||
'org_name', | ||
'org_activity', | ||
'description', | ||
'month_start', | ||
'year_start', | ||
'month_end', | ||
'year_end', | ||
'user_id', | ||
]; | ||
|
||
public function user() | ||
{ | ||
return $this->belongsTo(User::class); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\WorkExperience; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class WorkExperienceFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = WorkExperience::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'position' => $this->faker->text(25), | ||
'org_name' => $this->faker->text(50), | ||
'org_activity' => $this->faker->text(50), | ||
'description' => $this->faker->paragraph(5), | ||
'month_start' => $this->faker->monthName(), | ||
'year_start' => $this->faker->year(), | ||
'month_end' => $this->faker->monthName(), | ||
'year_end' => $this->faker->year(), | ||
'user_id' => $this->faker->numberBetween(1,10), | ||
]; | ||
} | ||
} |
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.