I am facing an unwanted and odd problem in my project. It's showing in one of my module's main index pages, displaying the following error.
TypeError: Cannot read properties of null (reading 'name').
In CPanel hosting
I have already checked the casing (OK). I tried to create another module (similar problem). Have a laravel through relationship in parent model(company). It's fine on my local machine and creates; edit route works fine in the live server (also, I have similar crud, which works fine)
Controller
public function index(Request $request)
{
return Inertia::render('Pesticides/Index', [
'pesticides' => Pesticide::with('company')
->filter($request->all())
->sorted()
->paginate()
->withQueryString(),
'query' => $request->all(),
]);
}
Model
class Pesticide extends Model
{
public function units()
{
return $this->belongsTo(Unit::class);
}
public function company()
{
return $this->belongsTo(Company::class);
}
public function pesticideSale()
{
return $this->hasMany(PesticideSale::class);
}
}
Please help.
I appreciate any help you can provide.