see: https://stackoverflow.com/questions/58882690/what-is-the-correct-way-to-pass-3-where-conditions-in-the-same-function-mult/58883277?noredirect=1#comment104033826_58883277 to better understand

based on laravel's documentation, I came up with the following result:

   public function loadpage($name, $page_name, $pcode)
        $company = Company::where('name', $name)->first();
        if ($company === null) {
              return view('company.not_register', compact('name')); 
        $page = Page::where([ ['name', $name],
    ['page_name', $page_name],])->first();
        if ($page === null) {
              return view('company.pages.erros.404', compact('name', page)); 

        $pagecode = Page::where([ ['name', $name],
    ['page_name', $page_name], ['code', $pcode],])->first();
        if ($pagecode === null) {
              return view('company.pages.erros.invalid_code', compact('company, name', page, pcode)); 

        $personality = DB::table('personalities')->where('name', $name)->first();

         return view('company.pages.index', compact('company', 'name', 'personality', 'page', pcode));

now it's up to colleagues more experienced than me to see if that's right or is it possible to improve / simplify



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.