davidtrushkov / store

A ecommerce store using Laravel 5.2
87 stars 62 forks source link

I can't access admin page. #5

Open joelezeu opened 8 years ago

joelezeu commented 8 years ago

I can't access admin page after verifying user and changing "admin" column to 1.

I am getting the following errors.

ErrorException in 23e7a0e4f26381d407fc30109565cd548e3cb857.php line 30: Trying to get property of non-object (View: C:\wamp64\www\store\src\resources\views\admin\pages\partials\count_carts.blade.php) (View: C:\wamp64\www\store\src\resources\views\admin\pages\partials\count_carts.blade.php)

in 23e7a0e4f26381d407fc30109565cd548e3cb857.php line 30 at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44 at PhpEngine->evaluatePath('C:\wamp64\www\store\src\storage\framework\views/758da443c38c0bee0064b00f9978fed533010499.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'signedIn' => true, 'user' => object(User), 'cart_count' => '0', 'orders' => object(Collection), 'users' => object(Collection), 'carts' => object(Collection), 'count_total' => '6944.92', 'products' => object(Collection), 'product_quantity' => object(Collection))) in CompilerEngine.php line 59 at CompilerEngine->get('C:\wamp64\www\store\src\resources\views/admin/pages/index.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'signedIn' => true, 'user' => object(User), 'cart_count' => '0', 'orders' => object(Collection), 'users' => object(Collection), 'carts' => object(Collection), 'count_total' => '6944.92', 'products' => object(Collection), 'product_quantity' => object(Collection))) in View.php line 149 at View->getContents() in View.php line 120 at View->renderContents() in View.php line 85 at View->render() in Response.php line 53 at Response->setContent(object(View)) in Response.php line 199 at Response->__construct(object(View)) in Router.php line 1087 at Router->prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 95 at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96 at ControllerDispatcher->callWithinStack(object(AdminController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54 at ControllerDispatcher->dispatch(object(Route), object(Request), '\App\Http\Controllers\AdminController', 'index') in Route.php line 174 at Route->runController(object(Request)) in Route.php line 140 at Route->run(object(Request)) in Router.php line 724 at Router->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 28 at Authenticate->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Admin.php line 22 at Admin->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Admin), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Router.php line 726 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699 at Router->dispatchToRoute(object(Request)) in Router.php line 675 at Router->dispatch(object(Request)) in Kernel.php line 246 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32 at Pipeline->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Kernel.php line 132 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99 at Kernel->handle(object(Request)) in index.php line 54

davidtrushkov commented 8 years ago

Is this how your table looks like in your Database?

admin

joelezeu commented 8 years ago

Yes

joelezeu commented 8 years ago

Please, help fix this bug, I want to start learning your code.

davidtrushkov commented 8 years ago

I just copied the project from here, and registered a new user, (Also set up my Database, and generated a new Laravel key) then went into the database and changed my fields and everything works fine. Did you modify the code, like changed something?

Here is how the file structure should look like for the Laravel 5.2 project:

test

( Dont worry about the .sql files )

irruzzz commented 8 years ago

the same with me :(

irruzzz commented 8 years ago

$cart->user->username ? not $cart->users->username ?

faveh commented 8 years ago

pls i have an issue, after installation and i directed my vhost to src/public, all i get is index of folders like css, images, less, sass, and vendor, folder. Thanks

davidtrushkov commented 8 years ago

To be honest, I have no idea why thats happening. Watch this video, and see how I structured my directory before making this project. Maybe this will help?

https://www.youtube.com/watch?v=ybJYyU5FPv4

Structuring this way is a bad idea though, so dont do it this way in future projects.

frogetii commented 7 years ago

change the mail.php in the config folder as follows. <?php

return [

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill",
|            "ses", "sparkpost", "log"
|
*/

'driver' => env('MAIL_DRIVER', 'smtp'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'host' => env('MAIL_HOST',  'smtp.gmail.com'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', '587'),

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => ['address' => 'yourname@gmail.com', 'name' => 'yourname'],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => env('MAIL_USERNAME','yourname@gmail.com'),

/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/

'password' => env('MAIL_PASSWORD','yourpassword'),

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',

];

Then change the .env file as follows;

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT= DB_DATABASE=davidtru_store DB_USERNAME=root DB_PASSWORD=

CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=yourname@gmail.com MAIL_PASSWORD=yourpassword MAIL_ENCRYPTION=tls

then clear cache;

php artisan config:cache

frogetii commented 7 years ago

Restart your local server

Try visit your route with controller contains mail function at first time it still error Authentication Required. You need to login via your gmail account to authorize untrusted connection. Visit this link to authorize