Fixed routing and backend to staff section
This commit is contained in:
parent
97af5273be
commit
600bbe7746
|
@ -16,10 +16,10 @@ class StaffController extends Controller
|
||||||
// $this->middleware([ "auth" ])->only("logout");
|
// $this->middleware([ "auth" ])->only("logout");
|
||||||
// $this->middleware([ "guest" ])->only("login");
|
// $this->middleware([ "guest" ])->only("login");
|
||||||
//
|
//
|
||||||
// $this->middleware([ "permission:user.list", "role:admin" ])->only("index");
|
// $this->middleware([ "permission:staff.list", "role:admin" ])->only("index");
|
||||||
// $this->middleware([ "permission:user.show", "role:admin" ])->only("show");
|
// $this->middleware([ "permission:staff.show", "role:admin" ])->only("show");
|
||||||
// $this->middleware([ "permission:user.edit", "role:admin" ])->only([ "edit", "update" ]);
|
// $this->middleware([ "permission:staff.edit", "role:admin" ])->only([ "edit", "update" ]);
|
||||||
// $this->middleware([ "permission:user.delete", "role:admin" ])->only("delete");
|
// $this->middleware([ "permission:staff.delete", "role:admin" ])->only("delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,9 +30,9 @@ class StaffController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$staff = Staff::query()->paginate($request->query("page", 20));
|
$staffs = Staff::query()->paginate($request->query("page", 20));
|
||||||
|
|
||||||
return Response::detect("staff.index", [ "staff" => $staff ]);
|
return Response::detect("staff.index", [ "staffs" => $staffs ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,9 +58,9 @@ class StaffController extends Controller
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
"name_first" => "required|max:255",
|
"name_first" => "required|max:255",
|
||||||
"name_last" => "required|max:255",
|
"name_last" => "required|max:255",
|
||||||
"email" => "required|email|unique:users",
|
"email" => "required|email|unique:staff",
|
||||||
"password" => "required|max:60",
|
"password" => "required|max:60",
|
||||||
"phone" => "required|unique:users",
|
"phone" => "required|unique:staff",
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class StaffController extends Controller
|
||||||
|
|
||||||
$staff = new Staff($data);
|
$staff = new Staff($data);
|
||||||
|
|
||||||
Log::debug("CREATED USER [NOT PERSISTED YET]");
|
Log::debug("CREATED STAFF [NOT PERSISTED YET]");
|
||||||
|
|
||||||
$staff->save();
|
$staff->save();
|
||||||
|
|
||||||
|
@ -121,25 +121,25 @@ class StaffController extends Controller
|
||||||
// $data = $request->validate([
|
// $data = $request->validate([
|
||||||
// "name_first" => "max:255",
|
// "name_first" => "max:255",
|
||||||
// "name_last" => "max:255",
|
// "name_last" => "max:255",
|
||||||
// "email" => "email|unique:users",
|
// "email" => "email|unique:staff",
|
||||||
// "password" => "max:60",
|
// "password" => "max:60",
|
||||||
// "phone" => "unique:users",
|
// "phone" => "unique:staff",
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
// Validates if the user is updating itself or another user.
|
// Validates if the staff is updating itself or another staff.
|
||||||
// if($id === Auth::id()) {
|
// if($id === Auth::id()) {
|
||||||
// $user = Auth::user();
|
// $staff = Auth::staff();
|
||||||
//
|
//
|
||||||
// $user->update($data);
|
// $staff->update($data);
|
||||||
//
|
//
|
||||||
// $user->save();
|
// $staff->save();
|
||||||
// return Response::detect("users.edit", [
|
// return Response::detect("staff.edit", [
|
||||||
// "user" => $user
|
// "staff" => $staff
|
||||||
// ]);
|
// ]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//TODO: Implement when security's ready!!!
|
//TODO: Implement when security's ready!!!
|
||||||
// else if(Auth::user()->hasPermissionTo("user.edit")) {
|
// else if(Auth::staff()->hasPermissionTo("staff.edit")) {
|
||||||
$staff = Staff::find($id);
|
$staff = Staff::find($id);
|
||||||
|
|
||||||
/** @var Staff $staff */
|
/** @var Staff $staff */
|
||||||
|
@ -150,7 +150,7 @@ class StaffController extends Controller
|
||||||
|
|
||||||
$staffs = Staff::query()->paginate(20);
|
$staffs = Staff::query()->paginate(20);
|
||||||
|
|
||||||
return Response::detect("users.index", [
|
return Response::detect("staff.index", [
|
||||||
"staffs" => $staffs
|
"staffs" => $staffs
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,43 @@
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
class Staff extends Model
|
class Staff extends Model
|
||||||
{
|
{
|
||||||
//
|
use Notifiable;
|
||||||
|
use HasRoles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name_first', "name_last", 'email', 'password', "phone"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password', 'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function setPasswordAttribute($password) {
|
||||||
|
$this->attributes["password"] = Hash::make($password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,15 @@
|
||||||
<a href="{{ route("contacts.create") }}" class="text-white"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Kontakt</a>
|
<a href="{{ route("contacts.create") }}" class="text-white"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Kontakt</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="segment">
|
||||||
|
<h3 class="text-white">Personale</h3>
|
||||||
|
<div class="row">
|
||||||
|
<a href="{{ route('staff.index') }}" class="text-white"><img src="{{ asset('/images/icons/eye.svg') }}" alt="Read">Vis Personale</a>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<a href="{{ route('staff.create') }}" class="text-white"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Personal</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-85" style="background-color: #cccccc;">
|
<div class="w-85" style="background-color: #cccccc;">
|
||||||
<div class="directorypath text-white">
|
<div class="directorypath text-white">
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
<td>{{ $staff->name_last }}</td>
|
<td>{{ $staff->name_last }}</td>
|
||||||
<td>{{ $staff->email }}</td>
|
<td>{{ $staff->email }}</td>
|
||||||
<td>{{ $staff->phone }}</td>
|
<td>{{ $staff->phone }}</td>
|
||||||
<td><a href="{{ route("users.edit", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
<td><a href="{{ route("staff.edit", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="{{ route("users.destroy", [ "staff" => $staff ]) }}" class="w-100">
|
<form method="post" action="{{ route("staff.destroy", [ "staff" => $staff ]) }}" class="w-100">
|
||||||
@csrf
|
@csrf
|
||||||
@method("delete")
|
@method("delete")
|
||||||
|
|
||||||
|
@ -38,5 +38,5 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{{ $staff->links() }}
|
{{ $staffs->links() }}
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Reference in New Issue