Now I am seem to be getting a problem where the if statement is ignored completely, $x is set to Users but its jumping into the first statement as if $x was set to Fees.
Its giving me this error which is strange because before trying out this new tactic in displaying each set of data individually it was working fine.
Invalid argument supplied for foreach() (View: C:\Users\Josh\Desktop\Projects\spatie-permissions\resources\views\livewire\show-fees.blade.php) (View: C:\Users\Josh\Desktop\Projects\spatie-permissions\resources\views\livewire\show-fees.blade.php)
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Fee;
use App\Models\Grade;
use App\Models\Injury;
use App\Models\Payment;
use App\Models\Report;
use App\Models\Subject;
use App\Models\TimeTable;
use App\Models\User;
class ShowAdmins extends Component
{
public $x = "Users";
public $data;
private function Fee() {
$this->x = "Fees";
}
private function Grade() {
$this->x = "Grades";
}
private function Injury() {
$this->x = "Injuries";
}
private function Payment() {
$this->x = "Payments";
}
private function Report() {
$this->x = "Grades";
}
private function Subject() {
$this->x = "Subjects";
}
private function TimeTable() {
$this->x = "TimeTables";
}
private function User() {
$this->x = "Users";
}
public function render()
{
if ($x = "Fees") {
$data = Fee::all();
return view('livewire.show-fees')->with('data', $data);
} else if ($x = "Grades") {
$data = Grade::all();
return view('livewire.show-grades')->with('data', $data);
} else if ($x = "Injuries") {
$data = Injury::all();
return view('livewire.show-injuries')->with('data', $data);
} else if ($x = "Payments") {
$data = Payment::all();
return view('livewire.show-payments')->with('data', $data);
} else if ($x = "Reports") {
$data = Subject::all();
return view('livewire.show-reports')->with('data', $data);
} else if ($x = "Subjects") {
$data = TimeTable::all();
return view('livewire.show-subjects')->with('data', $data);
} else if ($x = "TimeTables") {
$data = User::all();
return view('livewire.show-time-tables')->with('data', $data);
} else if ($x = "Users") {
$data = User::all();
return view('livewire.show-users')->with('data', $data);
} else {
$data = User::all();
return view('livewire.show-users')->with('data', $data);
}
}
}