未定义的变量:UserModel。尝试显示可验证模型中的内容

时间:2017-10-09 07:56:58

标签: mysql laravel xampp

我正在尝试显示这些东西但导致错误,其中我显示的其他东西,但在模型中有使用Authenticate,我没有得到它如何显示。因为我不太喜欢laravel

路线:

Route::post('profile', 'RegisterController@show');

控制器:

public function show()
    {
        $UserModel=UserModel::all();
        return view('profile')->with('UserModel',$UserModel);
    }

型号: 命名空间App;

use Illuminate\Database\Eloquent\Model;
use Input;
use Hash;

use Illuminate\Foundation\Auth\User as Authenticatable;

class UserModel extends Authenticatable
{
    protected $table = 'doctor_dbs';
    protected $primaryKey = 'doc_id';

    protected $fillable=['doctor_name','contact_no','email'];

    protected $hidden = [
        'password','password_again','remember_token',
    ];


    public static function UserStore($data)
    {
        $doctor_name = Input::get('doctor_name');
        $contact_no = Input::get('contact_no');
        $email = Input::get('email');
        $password = Hash::make(Input::get('password'));

        $users = new UserModel();

        $users->doctor_name=$doctor_name;
        $users->contact_no=$contact_no;
        $users->email=$email;
        $users->password=$password;

        $users->save();
    }
} 

查看个人资料文件名:

 @foreach($UserModel as $key=>$row)
    <tr>
        <td>{{$row->doctor_name}}</td>
    </tr>
    <tr>
        <td>{{$row->contact_no}}</td>
    </tr>
    <tr>
        <td>{{$row->email}}</td>
    </tr>
@endforeach

0 个答案:

没有答案