GTHell

Experience

6,690

0 Best Reply Awards

  • Member Since 11 Months Ago
  • 8 Lessons Completed
  • 0 Favorites

12th August, 2018

GTHell left a reply on Check If User Authenticated? • 3 days ago

@jlrdw I'm not doing authentication. I just learnt that just call the ajax in the web.php instead of api.php and have the if(request()->ajax()) to check if it ajax request. Now a GET controller can serve as both ajax and normal http request and Auth::check() work now because now it's session instead of request from api.php.

Thank for all the answers though.

GTHell left a reply on Check If User Authenticated? • 3 days ago

Oh, I just found out the main problem is it's an AJAX. On normal controller that pass through web.php can detect the Auth::check() but the same controller with api.php return false upon calling Auth::check(). What am I suppose to do in this scenario? My frontend is using Vue component and I'm calling axios in vuex.

GTHell started a new conversation Check If User Authenticated? • 3 days ago

How do I check if user authenticated? Google result is not helpful since 90% of the answers is to use auth middleware. Lol, I want to perform some query on homepage if user authenticated.

11th August, 2018

GTHell left a reply on Should Cart Store In LocalStorage Or Cookie? • 4 days ago

@click safari *kinda has problem with everything. Some open source has a fall back to cookie if local storage not support. That's a lot of work. Not saying that's hard but time consuming.

GTHell left a reply on Should Cart Store In LocalStorage Or Cookie? • 4 days ago

@click Can you explain on what you said ". You only need to make it possible to link it to a session id (or a key that you store in a cookie) instead of an actual user"?

@Cronix My cart is vue component and I decide to use localStorage. Look like a lot of more works to get it done right. Currently, I want the login user to get the cart from the client. I don't know how to do that with localStorage yet. Maybe send it through hidden input in login form but I'm not sure.

I don't know about session storage. Maybe I should take a look now.

GTHell started a new conversation Should Cart Store In LocalStorage Or Cookie? • 4 days ago

Help me analyze this. I have a cart that can be use anonymously. That mean I need some sort of storage to store it in client side. I didn't know better between the two options. The localStorage seem good for having a bigger size but cookie send to server with every request which is good and easier to working with authentication to detect the client cart and the cart that auth user currently had.

7th August, 2018

GTHell left a reply on Get Top Review Products? • 1 week ago

@Cronix you mean choose best answer?

GTHell left a reply on Get Top Review Products? • 1 week ago

@Cronix I thought that there would be a way without iterating. Alright cool! Have a nice day.

6th August, 2018

GTHell left a reply on Get Top Review Products? • 1 week ago

@Cronix I already get it working but just asking because I didn't know that the order doesn't matter except the get(). Also, I have Top Review Product, Top Sell Product. Getting this to work will also get the other one to work.

Anyway, is it possible to get only the product column?

GTHell left a reply on Get Top Review Products? • 1 week ago

@staudenmeir Oh, I didn't think about that. What type of rating do you have in mind?

@Cronix I'm not fully understand about the with() and the selectRaw() part. Can we chain selectRaw after already specify select and after the eager loading?

GTHell started a new conversation Get Top Review Products? • 1 week ago

I have problem with getting the top selling products.

I have 2 tables, products, and product_reviews

  • products(id, name, price)
  • product_reviews(id, product_id, rating)

a product can has many product_reviews

============================== product ============================== id | Name | price

1 | Book . | 100 2 | Sock | 5000 3 | Strape | 9000

============================== product_reviews ============================== id | product_id | rating

1 | 1 | 4 2 | 1 | 5 3 | 2 | 5 4 | 1 | 3 5 | 2 | 4 6 | 1 | 5 7 | 3 | 4

As you can see, the product with id 1 probaby has the most review and good review also.

How do I use eloquent to get the result?

3rd August, 2018

GTHell started a new conversation Is Going Full SPA Good? • 1 week ago

Guys, I want to build site similar to laracasts discussion. I see that it's not SPA. I really don't know the pros and cons of SPA at all.

The problem that going to happen with SPA is probably SEO and security. What to consider?

25th July, 2018

GTHell left a reply on Is Laravel Auth Method Is Just A Php Session? • 3 weeks ago

@Cronix Alright cool. So, basically is JWT & Session is the prefer method this day? I thought there're alternative to session/cookie being use by big tech like Facebook.

GTHell left a reply on Is Laravel Auth Method Is Just A Php Session? • 3 weeks ago

@Cronix No intention to simplify it. It's complicate pattern, though.

Do you know the authentication method uses by Facebook or Google? Is it also session based since Facebook is PHP.

GTHell started a new conversation Is Laravel Auth Method Is Just A Php Session? • 3 weeks ago

Is it a session based authentication?

17th July, 2018

GTHell left a reply on Can You Provide Me A Simple Concept Of Authentication With JWT? • 4 weeks ago

@jlrdw thx for the article.

@tykus What does the auth:api middleware do exactly?

15th July, 2018

GTHell started a new conversation Can You Provide Me A Simple Concept Of Authentication With JWT? • 1 month ago

I kinda not understand about the JWT authentication using jwt-tymondesigns. After following the document they provided I have a login, register, logout ...etc and I'm struggling to understand how do I save the user to in the front-end? Do I need to store the token in session and then have a middleware to check for token or what I'm confusing.

4th July, 2018

GTHell left a reply on Use Magento For CMS Or Build It Myself? • 1 month ago

Yes, I'm looking for ecommerce specific platform.

GTHell started a new conversation Use Magento For CMS Or Build It Myself? • 1 month ago

What is good option for a quick but scalable project?

2nd July, 2018

GTHell started a new conversation When To Have Foreign Key Constraint? • 1 month ago

When to have a constraint?

GTHell left a reply on How Only Allow Authenticated User To Do API Request? • 1 month ago

Alright cool. @Snapey I have one more question I don't want to open a new thread. How do I prevent other use to access my API in the api.php? I give the middleware api to the route but postman still can access the API.

GTHell left a reply on How Only Allow Authenticated User To Do API Request? • 1 month ago

Thank you for answer!! Does it mean that Ajax should be call with route.php instead of api.php? I have a Like button similar to this Laravel discussion and I put it in api.php.

1st July, 2018

GTHell left a reply on How Only Allow Authenticated User To Do API Request? • 1 month ago

@Cronix yes, if I have a user authenticated via the default guard Auth and that user want to do API request then how do the API.php know that the it's the authenticated user if there's no token?

GTHell left a reply on How Only Allow Authenticated User To Do API Request? • 1 month ago

@cronix what if I also has the authentication with session? How would the session authenticated user has token?

GTHell started a new conversation How Only Allow Authenticated User To Do API Request? • 1 month ago

I'm learning to do authentication with jwt + vue. What is the right way to check for authentication?

I'm thinking of giving middleware to API route but I don't know how to do it.

GTHell left a reply on Is Querying In View Bad? • 1 month ago

@burlresearch That's a good one. I almost forget that Laravel has a map function

@martinbean Is this considering bad or I should do as @burlresearch? You see, in code below, I call recentArticles() directly in view.

     {
         //
+        $cats = NewsCategory::all();
+        return view('news.category.index')->with('cats', $cats);
     }
 @foreach($cat->recentArticles() as $article)
+                            <div class="col l4 m4 s12">
+                                <div class="card">
+                                    <div class="img-card">
+                                        <a href="/news/" class="feature-image"
+                                           style="background-image:url('')"></a>
+                                    </div>
+                                    <div class="card-content">
+                                        <a href="/news/"
+                                           class="card-title activator grey-text text-darken-4">adslkfj asd;fjk
+                                            as;kdjf </a>
+                                        {{--                                {!!  strlen($article['feature_article'])<50 ? $article['feature_article'] : substr($article['feature_article'],0,50)."..." !!}--}}
+                                        sadkjfkl;ajs klsadjf kljs jsadfj sakdj kasjdf kjasd jkasdjk
+                                    </div>
+                                </div>
                             </div>
@endforeach

30th June, 2018

GTHell left a reply on Is Querying In View Bad? • 1 month ago

@burlresearch how would you query sub article of each category and then pass it to views?

I would do that by query the all the recent articles of each category and push all of them to the same array then chunk them by n number. For instance, If I have 3 category and I want 2 article per category then I would have an array of 6 article from those 3 category and chunk them by 2. In view, I would get each chunk by their index. It work but I just think it's not good.

GTHell started a new conversation Is Querying In View Bad? • 1 month ago

I have a news page showing categories and each category need to show three recent article. How do I do that without query the article in view?

27th June, 2018

GTHell left a reply on Is It Possible To Make Payment Gateway Without Using Service Like Stripe? • 1 month ago

WooCommerce use stripe that why I said it's even easier to run ecommerce. That link you refer to, I've already take a look before. It's seem like I have no option left.

@Cronix Come here join me and become a millionaire together. What do you think?

25th June, 2018

GTHell left a reply on Vagrant, Docker Or What? • 1 month ago

I'm setting up for production. My plesk panel is messy with php, composer and node. I'm thinking of reinstalling it. On my dev machine there is no need for environment because, you know, my macbook only has 128gb.

GTHell left a reply on Is It Possible To Make Payment Gateway Without Using Service Like Stripe? • 1 month ago

I'm from Cambodia. Paypal can only accept credit card but can not withdraw it back to my visa card. I'm literally stuck. Everyone in US can open an ebusiness so easily with just woocommerce and registering a business is so cheap there.

The local bank here require a lot of paper work and without a ton of money, the paper work can take really long. Company registration, patent, 6 months of transaction.... how can a startup has 6 months of transaction, seriously?

I wonder if there a solution that work globally? If payment gateway is a problem then is there any design that an ecommerce could use, like bank wire?

GTHell started a new conversation Is It Possible To Make Payment Gateway Without Using Service Like Stripe? • 1 month ago

I got a problem with service like Stripe, paypal.. etc that's not available in my country. The only solution is local bank and I'm not buying it. Another solution is to open bank account in country like US, not possible.

23rd June, 2018

GTHell started a new conversation Vagrant, Docker Or What? • 1 month ago

Too many to choose for beginner. I use Docker but I don't even know how it work because I just google everything to get it work on my server. But now on my own hosting, I want to use something else. Is docker still better?

I'm vultr 5$/month.

21st June, 2018

GTHell left a reply on Multiple Pivot Table Or One Pivot Table With Multiple Columns? • 1 month ago

@shez1983 I just made one table with all the field as true or false. How do you come up with naming those pivot table?

GTHell started a new conversation What Auth Middleware To Use When Doing Ajax From Authenticated User? • 1 month ago

currently, In my api.php I have a route for ajax but I didn't give it any middleware. The user will redirect to the login page on any link that require ajax. I'm curious what middleware to use in this case?

I've try auth and auth:api in the route and it both not work.

GTHell started a new conversation Multiple Pivot Table Or One Pivot Table With Multiple Columns? • 1 month ago

What is better when designing a many-to-many relation? For instance, I have a table users has relationship with projects table and the column that has many to many are like, add_to_watchlist, and transaction. I wonder if I should store this three in one pivot table or separate them all?

GTHell left a reply on Payment Gateway That's Not Stripe Or Braintree? [Closed] • 1 month ago

@Sergiu17 I just research more on this and it's seem that non of the method will available for my country but local bank. And local bank require company to register and has transaction for over 6 month. Now I know why startup in the US is much much more easier.

20th June, 2018

GTHell started a new conversation Payment Gateway That's Not Stripe Or Braintree? • 1 month ago

Stripe is not support in my country.

19th June, 2018

GTHell left a reply on Redirect The Previous Link After Login? • 1 month ago

@grenadecx that's what I'm going to do if I can't get answer to my original problem. I'm just not sure why this happen and what is the different doing it manually vs redirect()->intended().

GTHell left a reply on Can't Seem To Get My Jquery Node_module Loaded In App.js • 1 month ago

You can try putting it inside body tag instead of head tag.

GTHell left a reply on What For Is Default App.js And Bootstrap.js? • 1 month ago

I like to think that static library like axios or jquery that use through all the app should only require one and bootstrap is a great place for them. Something that is more dynamic like Vue.js or React.js should be extend and create yourself.

GTHell left a reply on Redirect The Previous Link After Login? • 1 month ago

I have setup 2 auth. One is original user Auth and another is Admin auth. I didn't touch the Login controller so the redirect()->intended('dashboard') is left untouch. It seem to work on fresh install though but my project is way to far to redo.

Here's the code that I customize: App\Exceptions\Handler.php

....
/**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Exception $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        if ($exception instanceof AuthenticationException) {
            $guard = array_get($exception->guards(), 0);

            switch ($guard) {
                case "admin":
                    return redirect((route('admin.login')));
                    break;
                default:
                    return redirect((route('login')));
                    break;
            }
        }

        return parent::render($request, $exception);
    }
.....

LoginController.php (Left un-touch)

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/dashboard';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

GTHell started a new conversation Redirect The Previous Link After Login? • 1 month ago

I can get it work passing some parameter but is there a standard way?

14th June, 2018

GTHell left a reply on Pivot Table Only Return User_id & Project_id • 2 months ago

@tykus It's catcha situation when I skim through the document.

It return all the project that association.

GTHell started a new conversation Pivot Table Only Return User_id & Project_id • 2 months ago

I have user that can has many projects and vice versa. I have table call user_project with a few column but when query using eloquent $user->projects->find(1)->pivot I only get user_id and project_id. Where is the rest of the column?

11th June, 2018

GTHell started a new conversation What Are The Best Way To Mix Front End Static Content To Dynamic Backend? • 2 months ago

I have this project where every single page is inconsistent that the front-end guy need to enter it manually. The page requires to have some functionality like user add to watchlist and more.

I'm thinking of putting the id of project into those button. The same concept as using @foreach but there might be a better way, isn't it?

GTHell left a reply on If SPA Is A Thing Why Not Many Website Migrating To It? • 2 months ago

Isn't server side rendering there to solve that problem?

9th June, 2018

GTHell left a reply on If SPA Is A Thing Why Not Many Website Migrating To It? • 2 months ago

@CJJ Reddit is moving to React slowly over these months and now their platform is React only. I don't see why Amazon or other platform can't do the same.

@martinbean Why is everyone so hype with SPA like Vue or Reactjs? It take me 2-3x times to build something that can be done faster with static page but the benefit is also that I can build frontend functionality 5x times faster than static page with jQuery.

8th June, 2018

GTHell started a new conversation If SPA Is A Thing Why Not Many Website Migrating To It? • 2 months ago

Assume that they have resource and good engineer, why won't they migrate to SPA? I'm building a shopping ecommerce with SPA and I just don't see any popular ecommerce website has SPA. Why?

7th June, 2018

GTHell started a new conversation How To Tell To User That My Website Is Base On Laravel? • 2 months ago

I'm building a backend portfolio and I have a VPS so I have infinite sub-domain. I want to show off my technology but I don't want to screenshot. Is there something like PHPInfo() ?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.