I need display My users table data in index.blade.php file. but when I visit index view it display an empty page only not display any variables data which I need.(no any errors dispaly)
index.blade.php
@if(isset($users))
@foreach($users as $use)
<h1></h1>
@endforeach
@endif
UsersController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\User;
use App\Http\Requests;
class UserController extends Controller
{
public function index()
{
$users = User::userr()->get();
// $users = User::all();
return view('users.index')->withUser($users);
//dd($users);
}
}
User.php Model
<?php
namespace App;
use Auth;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'username', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getAvatarUrl()
{
return "http://ift.tt/ww139j" . md5(strtolower(trim($this->email))) . "?d=mm&s=40";
}
public function scopeUserr($query)
{
return $query->where('username',Auth::user()->id);
}
}
Can You give me some solutions?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire