when i log as admin i got data from data base when i log as tenant the data is null.
i create table where user can click name and go to show page to show the profile of other user but my problem is when i click the name as admin i got some data when i log as tenent i got null value,
i try to dd() the the user form userController show but the connection in admin has value when i log as tenant the connection is null pls help me thank you. I’m beginner in laravel 11
admin dd
tenant dd
Link @inertiajs/react
// admin side
<Link href={route("user.edit",row.id)} >Edit</Link>
// tenant side
<Link href={route("User.show",row.id)} >{row.id}</Link>
//userConnetroller
public function show(User $user){
if(Auth::user()->type ==="tenant"){
dd($user);
return inertia("Tenant/Show", [
'Owner' =>new UsersResource($user),
]);
}
if(Auth::user()->type ==="admin"){
dd($user);
return inertia("Profile/Show", [
'User' => new UsersResource($user),
]);
}
}
//UsersResource
public function toArray(Request $request): array
{
//only see post
return [
"id" => $this->id,
"name" => $this->name,
"email" => $this->email,
"address" => $this->address,
"type" => $this->type,
"status" => $this->status,
"contact_Number" => $this->contact_Number,
"Facebook" => $this->Facebook,
"BH_name" => $this->BH_name,
"created_at" => (new Carbon( $this->created_at))->format("Y-m-D"),
"updated_at" => (new Carbon( $this->updated_at))->format("Y-m-D"),
];
}
//admin and tenant meddleware
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()->type === 'admin') {
return $next($request);
}
return redirect()->route('/Admin/Dashboard');
}
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()->type === 'tenant') {
return $next($request);
}
return redirect()->route('/Tenant/Dashboard');
}
data receiver react
//tenant receiver
function Show({auth,Owner}) {
const data = Owner.data;
//admin receiver
function Show({auth,User}) {
const data = User.data;
Koro-sensei is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.