Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aurelo's avatar

Laravel 5.6 app to shared hosting

Hi, my app is works on local server (xampp php version 7.2.4). I uploaded my app to shared webhosting (php version 7.2.4)) and me app does not work properly. It does not show me a listing (example tables with multiple @foreach @if ).

I am download me app from share hosting to locel serve and app on local works smoothly (also with the database share hosting).

I tried clearing the cache (view:clear, route:clear, cache:clear, config:clear) but it did not help.

Where could be the problem?

Thank you very much.

Next I add a code snippet that works on local server but does not work on shared server:

                   <tr>
                                @foreach($contractstatus as $contractstatus2)
                                    @foreach($employy as $employy2)
                                        @foreach($client as $client2)
                                            @if(($contract->stav_zakazky===$contractstatus2->id)&&($contract->zodpovedna_osoba_id===$employy2->id)&&($contract->client_id===$client2->id))

                                                <td>{{ $employy2->meno}}</td>
                                                <td>{{ $contractstatus2->nazov_stavu}}</td>
                                                <td>{{ $client2->nazov_firmy}}</td>
                                                <td>{{ $contract->poradove_cislo }}</td>
                                                <td>{{ $contract->pocet_ks }}</td>
                                                <td>{{ $contract->odhadovany_cas }}</td>
                                            @endif
                                        @endforeach
                                    @endforeach
                                @endforeach

                            </tr>

EDIT: Problem solved: @if The condition must be == no ===.

0 likes
12 replies
Snapey's avatar

'does. not work' is not something people can help with

Please be more specific

Inquisitive's avatar

So, what is the error? You are not being specific.

Ther might be a lot of cases, maybe there is no data to populate foreach loop, also on many cases when you work on windows on the local machine, it might not be case sensitive, which would not be the case on Linux machine on the server.

Snapey's avatar

So the problem is you are not getting any data?

Focus on what is going on in the routes and the controller rather than the view.

I assume you can do other things with the database such as logging in?

aurelo's avatar

Some data I get from db, some not. Record data to database works. Login/register is works.

Code controller show contacts:

public function show(Contract $contract)
{
   // $contract = Contract::where('id',$contract->id);
    $contract= Contract::find($contract->id);
    $contractstatus= ContractsStatus::all();
    $client=Client::all();
    $defined_task= DefinedTask::all();
    $employy= Employees::all();
    $subdefined_task= SubdefinedTask::all();
    $download_files= DownloadFile::where('contract_id',$contract->id)->get();
    return view('contracts.show',['contract'=>$contract, 'defined_task'=>$defined_task, 'employy'=>$employy, 'subdefined_task'=>$subdefined_task, 'download_files'=>$download_files,'contractstatus'=>$contractstatus,'client'=>$client]);
}
Vilfago's avatar

O.o are you sure you have to load all your database to show a contract?

Snapey's avatar

Are you sure you have some data in the database?

aurelo's avatar

Yes, me local app joined db from shared hosting and local is works.

aurelo's avatar

Now I tested it on windows server and there it runs smoothly. Where can be a problem?

Inquisitive's avatar

Copy and paste the following after

$download_files= DownloadFile::where('contract_id',$contract->id)->get();

and show what it outputs

    

echo "Contract";   
echo 'pre>';
   print_r($contract);
echo '<pre>'

echo "Contract Status";

echo 'pre>';
   print_r($contractstatus);
echo '<pre>'

echo "client";
echo 'pre>';
   print_r($client);
echo '<pre>'

echo "defined_task";
echo 'pre>';
   print_r($defined_task);
echo '<pre>'

echo "employy";
echo 'pre>';
   print_r($employy);
echo '<pre>'

echo "subdefined_task";
echo 'pre>';
   print_r($subdefined_task);
echo '<pre>'

echo "download_files";
echo 'pre>';
   print_r($download_files);
echo '<pre>'
exit();

Also, make sure you have mentioned

use App/Client;

like these, Capital Client not client. You are mentioning some data are not present. Double check those name. Are they uppercased?

aurelo's avatar

Hi, I found a mistake: The error was in the conditions if. It must be used == no ===

Can you please explain the difference in condition if == and === .

Thank you all.

Please or to participate in this conversation.