mardi 8 septembre 2020

Laravel I want to display only employees in table

Hi I'm building a human resources management system, I want to display only users that are not admin in a data table but I'm getting error dont know what I might be doing wrong. Here is my code;

 <table class="table table-hover">
    <thead>
      <th>Username</th>
      <th>Department</th>
      <th>Salary</th>
    </thead>
    <tbody>
        @foreach($this->$users()->get() as $user)
        @if($user->is_admin !== 1)
        <tr>
          <td> </td>
          <td> </td>
          <td> </td>
        </tr>
        @endif
        @endforeach
    </tbody>

Table

 Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->boolean('is_admin')->nullable();
            $table->string('department')->nullable();
            $table->integer('salary')->nullable();
            $table->string('image',255)->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire