mercredi 3 avril 2019

ErrorException (E_ERROR) Trying to get property 'name' of non-object in laravel 5.5

I'm getting this error when I'm trying to access the variable I passed from the controller inside the view.I created the controller using the command php artisan make:controller CompaniesController --resource, so I have all the resource methods for use.

This is the route that I gave

Route::resource('/createcompany','CompaniesController' );

This is the function inside my controller

public function show($id)
{
  $company = Company::find($id);
  return view('pages.admin.showcompany')->with('company', $company);
}

Company has id and name as attributes

This is my view

@extends('layouts.app')

@section('content')

<h1> </h1>

@endsection

I looked up similar questions (this, this and this) but they were not helpful.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire