mercredi 10 mars 2021

Laravel where clause in controller

im new in programming and laravel, I want to ask how to select data from the Reqlowongan table that has not been filled in the Isilowongan table by detecting it with the mahasiswa_id attribute in Isilowongan table with the current mahasiswa_id being logged in. How to do it?

this is my table : https://i.stack.imgur.com/9vWcm.png

this is my controller :

public function index()
{
    $role = auth()->user()->role;
    $id = auth()->user()->id;
    if($role =='mahasiswa'){
        $lowongan = Reqlowongan::all();
        return view('indexMhs', compact(['lowongan']));
    }if($role =='instansi'){
        $lowongan = auth()->user()->instansi->reqlowongan;
        return view('indexIns', compact(['lowongan']));  
    }else{
        $lowongan = Reqlowongan::all();
        return view('IndexKp', compact(['lowongan']));  
    }
}

this is my blade

@foreach($lowongan as $lowongan)
        <tr>
            <th scope="row"></th>
            <td></th>
            <td></th>
            <td></td>
            <td class="text-center">
                <a href="/instansi//list_mahasiswa" class="badge badge-warning ml-2">DAFTAR </a>
            </td>
        </tr>
      @endforeach

i already try using where clause and if clause, but i dont know how and i cant do it, can you help me please?

Aucun commentaire:

Enregistrer un commentaire