vk011

vk011

Member Since 3 Years Ago

Experience Points 1,020
Experience Level 1

3,980 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 1
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

10 Aug
1 week ago

vk011 left a reply on Laravel Socalite - HandleProviderCallback Is Never Triggered

Yea I hear you, thanks for all the help.

vk011 left a reply on Laravel Socalite - HandleProviderCallback Is Never Triggered

OK friend we're getting there.

I am not using php artisan serve, I am using wamp and I run the app on localhost:3000 with browser sync / web pack, so not sure if I need to change anything there?

Ok I changed the redirect in my services.php, and in Valid OAuth Redirect URIs I now have http://localhost:3000//login/facebook/callback ( I do read what you say, I also tried changing it to http://localhost:8000//login/facebook/callback however now I get a new error on facebook website:

Facebook has detected olja isn't using a secure connection to transfer information.

So even though I am on localhost and in development mode I get this message.

Yea I just read your last post, not sure if http will work even on localhost.

vk011 left a reply on Laravel Socalite - HandleProviderCallback Is Never Triggered

@audunru I actually do have a redirect now, though thanks for letting me know it's the way to go, however still the problem of the method not being triggered persists.

I don't understand how am I supposed to be redirected to the callback route when facebook as you say does not connect to it. I think I might need to edit something in my facebook app or in services.php.

Please bear with me as I don't have much experience with this.

These are my routes:

Route::get('login/facebook', 'Auth\[email protected]');

Route::get('login/facebook/callback', 'Auth\[email protected]');

The actual website runs on http://localhost:3000/

In services.php I have

'facebook' => [
        'client_id' => 'myid',
        'client_secret' => 'mysecret',
        'redirect' => 'http://localhost/',
    ],

On my facebook app, I have localhost set for my App Domains (under Settings/Basic) and on that same page at the bottom I've added a website platform with site url of http://localhost:3000/

Under Products/Facebook Login/Settings , Valid OAuth Redirect URIs is empty.

Please tell me what needs changing? I tried changing my redirect in services.php to http://localhost:3000/login/facebook/callback however this gives me some error when trying to log in.

I also tried setting 'Valid OAuth Redirect URIs' to http://localhost:3000/login/facebook/callback but it won't accept it (I guess because of https)

So, my guess is I need to change my redirect in services.php and have that same redirect in Valid OAuth Redirect URIs, is that correct? If so, how do I do that on localhost? It seems to deman https for Valid OAuth Redirect URIs

vk011 left a reply on Laravel Socalite - HandleProviderCallback Is Never Triggered

Hi, are you sure?

Yes I am testing locally, but I don't think that's the issue.I think Facebook supports local development.

I think I do get logged in. I get a "state" session variable after logging in via facebook, and also I've implemented this facebook login locally without a framework or socialite (just 2 php scripts) and it worked fine.

vk011 started a new conversation Laravel Socalite - HandleProviderCallback Is Never Triggered

I am trying to log a user in via Facebook and then use that user data to fill out the name and email in a comment form.

I am using Laravel / Socialite.

So in my LoginController I have this:

public function redirectToProvider()
    {
        return Socialite::driver('facebook')->redirect();
    }

public function handleProviderCallback(Request $request)
{
    $user = Socialite::driver('facebook')->user(); 

    $request->session()->put('user', $user);
}

By using breakpoints in both methods I came to the conclusion that the handleProviderCallback method is actually never triggered for some reason.

09 Apr
4 months ago

vk011 started a new conversation Sharing Session Data Accross Views

How to share session data accross views?

Say I have a session key with some data, in a controller I'd get it like so:

$session = $request->session()->get('someSessionValue');

And then pass it on to the view, fair enough.

And if I wanted to share some non session data accross all views, in AppServiceProvider I'd do e.g.:

public function boot()
    {
        $logo = \App\Misc::where('name', 'logo')->value('content');

        View::share('logo', $logo);

    }

But I cannot do that with session data, is it possible?

vk011 left a reply on Pushing To Session Array With Custom Key

Custom index, e.g. I wanna do something like this (which doesn't work)

$request->session()->push('cart', 'customKey' => $productInfo); 

vk011 started a new conversation Pushing To Session Array With Custom Key

If I have a session value which is an array, I know I can just push to it, but can I push to it with a custom key?

$request->session()->push('cart', $productInfo); // can $productInfo here have custom key somehow?
06 Mar
1 year ago

vk011 started a new conversation Dropzone Events Not Firing

Hello,

I am using Laravel 5.6.

I've set up dropzone and it works as far as uploading goes, but the completemultiple event (or any other ) is not firing, any ideas?

Dropzone.options.dropzoneForm = {
            acceptedFiles: "image/*",
            maxFilesize: 10,
            init: function () {
                this.on('completemultiple', function () {
                    console.log('done');
                    location.reload();
                });
            }
        }

I am returning 200 from the upload method:

return response()->json(['success' => 'success'], 200);

Maybe I am not returning what I should so dropzone does not know when it is done?

26 Aug
1 year ago

vk011 left a reply on Cannot Change Base Url In Laravel 5.4

oh I see now, I thought it has something to do with it. I understand the dangers with public in the url, I wasn't gonna keep it so I just wondered why the url didn't work.

Thanks for clearing up app_url

vk011 left a reply on Cannot Change Base Url In Laravel 5.4

I don't want it in the root. I've made a subdomain and it works, but still I wonder buy just going to root/site/public doesn't work even when changing the app_url in the .env file

vk011 started a new conversation Cannot Change Base Url In Laravel 5.4

I have a website in myroot.com/laravelsite/public , and i can access it, but the root on the site is www.myroot.com instead of myroot.com/laravelsite/public.

i changed the .env app_url to be myroot.com/laravelsite/public and I did php artisan config:clear but it is still the same.

Any ideas?

25 Aug
1 year ago

vk011 started a new conversation Can't Get Laravel To Work On Live Server

Hi guys, In my root I created a subfolder called mysite.

  1. I created a folder inside of mysite called test and moved public files there and deleted the public folder

  2. I've set 777 to storage folder

But now when i go to root/mysite/test , instead of seeing the homepage, i see Internal Server Error

20 Oct
2 years ago

vk011 left a reply on Prevent Json Encode From Returning Arrays As Strings

Hey thank thanks for helping, yes double encoding seems to be the problem that needs to be solved, I managed to do it with some help from SO and it works, basically decode the whole thing and then decode just products and then encode the whole thing.

$s = DB::table('orders')->get();

        $orders = json_decode($s, true);

        $s = $orders[0]['products'];
        $orders[0]['products'] = json_decode($s, true);

        return json_encode($orders);
19 Oct
2 years ago

vk011 left a reply on Prevent Json Encode From Returning Arrays As Strings

Yes I think you are right, it is double encoding.

I am using json_encode to store a php array, and then retreive the whole row as json, out of which producs is just one column (but the only one with an array, or json in this case).

Is there a better way of storing the php array in the first place or something like that, because I have to retreive the whole row in one go, I do not see another way?

(I tried to json_decode on the query result but no difference)

vk011 started a new conversation Prevent Json Encode From Returning Arrays As Strings

I get the following json response when I query my database:

    [{"id":1,"name":"my name","street":"Sava Burica","city":"Belgrade","state":"Zemun","zip":"11080","country":"Serbia","giftwrap":null,"products":"[{\"count\":2,\"id\":1,\"price\":275,\"name\":\"Kayak\"},{\"count\":1,\"id\":2,\"price\":48.95,\"name\":\"Lifejacket\"}]"}]

e db the column is like so:

[{"count":2,"id":1,"price":275,"name":"Kayak"},{"count":1,"i‌​d":2,"price":48.95,"‌​name":"Lifejacket"}]``` angularjs is being used on frontend.

It is all good except that the products value is a string and it should be an array.

I am using Laravel 5.3.

Can I somehow force it to return arrays as arrays and not as strings?

15 Sep
2 years ago

vk011 started a new conversation Sticky Forms In Laravel 5

Hi guys, In Laravel 5 form helper does not exist anymore, so what is the best way to make forms sticky, so for example if validation fails for one input but is ok for another, the ok one should be remembered. I remember this was automatic with the html helper, but I wanna know if know there is another way since html helper is not part of laravel core anymore?

14 Sep
2 years ago

vk011 left a reply on @if ( ! Session()->has('user') || ! \Cookie::has('user') ) Not Working

I am just playing around, it can be something else, not necessarily authentication, I just wanna know why if (! session()->has('something') does not work.

vk011 started a new conversation @if ( ! Session()->has('user') || ! \Cookie::has('user') ) Not Working

Hi Laravel friends, I am using Laravel 5.3 and have a weird problem.

If I have a user session or cookie set and have the following code:

@if ( ! session()->has('user') || ! \Cookie::has('user') )
            <li><a href="{{ url('/register') }}">Register</a></li>
            <li><a href="{{ url('/login') }}">Login</a></li>
            @endif

The links always get displayed, but on the other hand if I have the following code:

@if ( session()->has('user') || \Cookie::has('user') )
            <li><a href="{{ url('/logout') }}">Logout</a></li>
            @else
            <li><a href="{{ url('/register') }}">Register</a></li>
            <li><a href="{{ url('/login') }}">Login</a></li>
            @endif

it works as expected, basically the register and login links don't get displayed if the session or cookie user is set.

So checking if a session or cookie is not set with ! does not seem to be working, any ideas why?

29 Jan
3 years ago

vk011 started a new conversation L4 - Fluent Problem Inside Foreach

Hello friends,

Inside the following code block, I am looping through an array of ids (there is actually just 1 id), and I get this error:

Undefined variable: id

However if I change

$query->where('seller_id', $id);

to

$query->where('seller_id', 10);

for example, I get the expected result. Why isn't it recognizing the $id inside the loop?

foreach ($ids as $id) {
            $true = DB::table('seller_images')
            ->where(function($query) 
            {
                $query->where('seller_id', $id);
            })
            ->where(function($query) 
            {
                $query->orWhere('passport_img', '!=', '')
                        ->orWhere('id_img', '!=', '')
                        ->orWhere('driving_img', '!=', '');
            })
            ->get();
            if ($true) $count = $id;
        }

        return $count;
28 Jan
3 years ago

vk011 started a new conversation Change Default Column Name 'id' When Validating

Hello friends,

I am trying to validate an email field so that I make sure it's unique, but not in a row with a certain id, which I do like so:

'email' => 'required|email|unique:seller_user,email,'.$seller_id,

That works, but it automatically searches for a column named id, whereas in my table that table is actually called seller_id, so how can I change that?

27 Jan
3 years ago

vk011 started a new conversation Laravel 4 Advanced Where Problem

return DB::table('profiles') ->where(function($query) { $query->where('verified', 0) ->where('vendor_type', '=', 3); }) ->orWhere('passport_img', '!=', '') ->orWhere('id_img', '!=', '') ->orWhere('driving_img', '!=', '') ->count();

I have 2 records in the table, one has a vendor_type of 1 and the other 3, this is supposed to return 1 result, that is verified and vendor_type are mandatory and out of the other 3 at least ONE should not be empty, however it keeps returning 2 instead of 1.

12 Jan
3 years ago

vk011 left a reply on Laravel 4 Pagination Links Ignore Existing GET Parameters

Got the answer on stackoverflow, $paginator->appends(['query' => $value])->links();

vk011 started a new conversation Laravel 4 Pagination Links Ignore Existing GET Parameters

Hello, I have a search in Laravel 4. After search for sh my url is this:

http://localhost/musiter/product/search-products/24?query=sh

I also have pagination there, but the pagination for the second link for example is:

http://localhost/musiter/product/search-products/24?page=2

instead of:

http://localhost/musiter/product/search-products/24?query=sh&page=2

Any way to fix this?

15 Dec
3 years ago

vk011 left a reply on Laravel 4 Redirect From Constructor This Webpage Has A Redirect Loop Error

No it is in a custom controller called AdminController.

The send method is laravel's built in method, returning a normal redirect from constructor does not work in Laravel for some reason.

vk011 started a new conversation Laravel 4 Redirect From Constructor This Webpage Has A Redirect Loop Error

In my controller I have the following:

function __construct() { Redirect::to('admin/login')->send(); } However after it redirects the browser gives the following error:

This webpage has a redirect loop How can I avoid this?

vk011 started a new conversation Laravel 4 Filter Route Not Working

I have an admin section in my app which works fine, however now I want to close it so only admin has access. Basically I want to redirect to admin/login if a non-admin person is trying to access admin pages.

This is my admin route (which works):

Route::controller('admin', 'AdminController');

I tried adding the following filter above the admin controller route, and I also commented out the local array element so the environment is set to production, but it is just not working.

Route::filter('isAdmin', function()
{
    if ( ! Session::has('admin') ) {
        return Redirect::to('admin/login');
    }
});

Route::get('admin', array('before' => 'isAdmin', function() 
{
    echo 'You are over 200 years old!';
}));

Route::controller('admin', 'AdminController');

So if now I go to mysite/admin , I still get to admin dashboard even though session admin does not exist.

12 Nov
3 years ago

vk011 started a new conversation Set Site Root In Laravel 4 So / Works Properly

I have my laravel app inside www/mylaravelapp folder, and if I use / for home link, as in HOME, for some reason it goes to localhost, not localhost/mylaravelapp.

But if if I use for example the Form helper, when I provide the url for the form, it works as expected, the url is correct, but in a 'a' tag in a view it is not.

Can I set my root domain somewhere so that it works as it should?