Русское сообщество разработки на PHP-фреймворке Laravel.
Ты не вошёл. Вход тут.
Не пойму в чем Проблема, или в Laravel 5.7 или на хостинге в BD.
Таблицы:
USERS, MEMBERS, COOPS, MEMBER_USER, COOP_USER
Связи таблиц:
Данные в таблицах:
Роут:
Route::group(['prefix'=>'admin', 'middleware'=>['web', 'auth']], function() {
Route::get('/', ['uses' => 'Admin\AdminController@show', 'as'=>'index']);
});
Когда такой код:
<?php
namespace App\Http\Controllers\Admin;
use App\User;
use App\Role;
use App\Apartament;
use App\Meeting;
use App\Coop;
use App\Member;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\View;
use Illuminate\Validation\ValidationException;
use BD;
use Auth;
//use Gate;
use Illuminate\Support\Facades\Gate;
class AdminController extends Controller
{
//
public function __construct() {
//$this->middleware('auth');
}
public function show(Request $request) {
$user = Auth::user();
if(!Auth::check()) {
return redirect('/login');
}
$user = User::find(Auth::id());
$member = $user->members;
$members = Member::find(Auth::id());
dd($member);
return view('admin.index');
}
}
то получаю коллекцию:
когда запускаю идентичный по логике код, а именно:
<?php
namespace App\Http\Controllers\Admin;
use App\User;
use App\Role;
use App\Apartament;
use App\Meeting;
use App\Coop;
use App\Member;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\View;
use Illuminate\Validation\ValidationException;
use BD;
use Auth;
//use Gate;
use Illuminate\Support\Facades\Gate;
class AdminController extends Controller
{
//
public function __construct() {
//$this->middleware('auth');
}
public function show(Request $request) {
$user = Auth::user();
if(!Auth::check()) {
return redirect('/login');
}
$user = User::find(Auth::id());
$coop = $user->coops;
$coops = Coop::find(Auth::id());
dd($coop);
return view('admin.index');
}
}
то в ответе:
Куда копать?
Не в сети