0

I setup the dependency injection as I felt it should go into my Patient Controller but for some reason it will never execute the dependency on the index function on the last line, it will even return the $request data before it but for some reason will not execute the data in the Patient Repository I attempt to return.

I have attempted to just do: return (new Patient)->getByAccNumAndDateOrZip($this->client_code, $this->account_number, $this->dob, $this->zip);

Also, keep in mind yes all $requests do have a valid value and do not return a empty or null value.

And still get nothing back....

namespace App\Http\Controllers\api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

//Repositories
use App\Repositories\Patient;

class PatientController extends Controller {
  private $patient;

  public function __construct(Patient $patient) {
    $this->middleware('auth.client');
    $this->patient = $patient;
  }

  public function index(Request $request) {
    //I can do return $request->client_code
    //But I can't use this dependency... It's weird...
    return $this->patient->getByAccNumAndDateOrZip($request->client_code, $request->account_number, $request->dob, $request->zip);
  }
}

I'm expecting to call to my dependency that pulls all the my patients by account number. The dependency is just a standard class with a namespace of App\Repositories it has no set constructor just a couple standard public functions that will take specific variables in the function.

5
  • Did you register the Patient repository in a service provider? Commented Jan 20, 2019 at 7:25
  • @Amade If I understand his comment, he's saying his Repository class is just a Standard class with no other dependencies so he wouldn't need to register it. Commented Jan 20, 2019 at 7:28
  • 1
    So if I understand correctly, if your app is not executing any of the code inside of the getByAccNumAndDateOrZip method? If so, is there anything in the error logs? Commented Jan 20, 2019 at 7:31
  • Nope nothing its just returning all blank. I also did attempt to clear out the function I was calling to with no data going to it and attempted to just do return "Test"; and still got nothing. Commented Jan 20, 2019 at 7:57
  • 1
    Checked the logs again and said that the Patient class name is already in used changed it to PatientRepository and its fixed! Commented Jan 20, 2019 at 8:17

1 Answer 1

1

After reviewing the log files in laravel I was able to see that the system was stating that the class name has already been used so I would have to choose something else.

This was suggested by Matt Wohler to check the logs and boy did it help me!

Thanks Again for all the help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.