vendredi 3 mars 2017

Calling model function in blade brake view - Laravel

I have two installation of laravel one local and the other one on a raspberry pi. I'm using a git repository to sync.

Everything is working fine except for one thing: I have one to many relation between teacher and schools.

This is my Teacher model:

Teacher - Model

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Teacher extends Authenticatable
{
    use Notifiable;

    protected $guard = 'teacher';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function students() {
      return $this->hasMany('App\Student');
    }

    public function school() {
      return $this->belongsTo('App\School');
    }
}

And this is the part where web version break

Teacher - View

@foreach ($teachers as $teacher)
              <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td><a class="btn btn-small btn-info" href="teachers/">View</a></td>
              </tr>
@endforeach

the most incomprehensible part is that in the local version of the app everything is working fine.

Thanks for you help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire