harit

harit

Member Since 2 Years Ago

Experience Points 950
Experience Level 1

4,050 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 0
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.

11 Jul
1 week ago

harit left a reply on Laravel In Amazon Server Cache Issue

The problem is sorted. It was due to permission.

when I run php artisan config:cache, the config.php inside bootstrap/cache folder is not updating to new values. (but not showing any errors also). I manually deleted the config.php and then tried. This time I got permission denied error. Then I logged as root user and tried then it worked

09 Jul
1 week ago

harit left a reply on Laravel In Amazon Server Cache Issue

bro Pls read the question first. I have cached the config earlier. But when the values changed, I have reseted the cache. the problem is , still the old values persisting.

harit left a reply on Laravel In Amazon Server Cache Issue

if im write the code in php file (in controller - echo Config::get('ClientId'); ) then it prints the old value only.

harit started a new conversation Laravel In Amazon Server Cache Issue

I have removed config cache using the artisan commands. But still the code is referring the old values. In order to check that I have echo the value in code. It seems the config cache is not removed or replaced with the new values in the server. Do any one have idea how to solve this? (To clear cache I used php artisan cache:clear and php artisan config:clear. then to update new values I did php artisan config:cache. I'm not getting any error in terminal while running the commands. )

03 Jun
1 month ago

harit left a reply on Laravel Mix Error

Ohh. I was supposed to remove the /public from the URL. I got that solution from stack overflow. If we can accomplish this with out moving public folder contents, that will be the best solution ( bcs then mix will work properly)

I'm not very good in server side setup, if you don't mind kindly explain how to point host file to public. And any reference links also welcome. I'm working in Apache Ubuntu environment

Thanks,

harit started a new conversation Laravel Mix Error

I have moved the index.php from public folder to avoid the /public from url. then I updated the webpack.mix.js with out public folder. so all the compiled files will create under the root folder/assets/ folder. Everything work fine. but when I compiling the assets (npm run watch), the manifest.json file created under public folder (i haven' removed public completely because it has link to storage). The file is creating perfect. But the key name lacking / except the mix.js file. Eg: the file name key is generating as assets/app/js/app.js rather than /assets/app/js/app.js.

When I'm calling mix('assets/app/js/app.js') it is not mapping to the file. If I edit manifest.json with / then it works. Do we have any permanent solution.

28 Dec
6 months ago

harit started a new conversation Can Use Laravel Passport For SSO

I have 1 laravel site and 3 wordpress sites on different domains. The laravel site need to work as a central application for user managment and authentication. If a user logged in laravel site then going to access wordpress site then that user must be identified by wordpress site (we will do wordpress part later). Here I think I can use Laravel passport to authenticate user. Once the login is done, the laravel site return access token to word press site1. Then If user visit wordpress site 2, then there also the user need to identified. Is that possible?

19 Nov
8 months ago

harit left a reply on Singleton Class Can't Resolve From Controller Constructor

@KVITHALANI - its already done. That is why this code (2nd snippet in the question) is working fine in side Action

harit started a new conversation Singleton Class Can't Resolve From Controller Constructor

In middleware I used this code to initialize a singleton class $aAccessData['is_super_admin'] = true; app()->singleton('AccessData', function ($app) use ($aAccessData) {

        return new \App\Services\AccessData($aAccessData);

    });

But if I'm resolving this class from controller, then it will thorw "Class AccessData does not exist" Error. Whereas if I resove the class with same code: $oAccessData = resolve('AccessData'); it works fine. What will be the reason

23 Aug
10 months ago

harit left a reply on JWT Token Expire In Website

solved the issue with passport. Thanks,

22 Aug
11 months ago

harit started a new conversation JWT Token Expire In Website

I'm using Tymon JWT package for authenticating my APIs for website. But I found, the token is expiring immediately when its life time expires. Sometimes it will expire in the middle when a user is using the application. Then the user need to re login to the system. But as per the user, he is active on the application and asking to relogin really hesitate him. I have tried different tricks like increase the life time of token, increase refresh token time etc. But when ever the time reaches the token become inactive irrespective the user is currently active on the system or not. Do anyone have better solution for this problem?

Is Laravel Passport can overcome the above issue? If I want to use passport, Is Implicit Grant Tokens is suitable here?

26 May
1 year ago

harit started a new conversation Compiled View Files To Amazone S3

To imporove performance, we would like to upload the compiled blade files in S3 bucket (along with other assets). Is there any package or tools available to accomplish this?.Also, Is it possible, when a view blade changes, the compiled file in the S3 bucket also need to reflect the changes (automatically).

23 Apr
1 year ago

harit left a reply on Laravel Guzzle Http Return Wrong Response

@Snapey I have tested this in 2 different way - 1) used virtual host for 2 apps by adding hosts in host file on windows http://local.app1.demo and http://local.app2.demo. But I found this is not working in the virtual host case also. 2) Then I moved app2 to another server (physically separated system). That time it worked as expected

21 Apr
1 year ago

harit left a reply on Laravel Guzzle Http Return Wrong Response

@Snapey, I have changed the code like this to add host: $this->client = new Client([ 'base_uri' => env('APPLICATION_LAYER_URL'), 'http_errors' => true, //must have false 'allow_redirect' => true, 'host' => 'www.app1.com' ]);

I have checked uri, it is pointing to correct action only

harit started a new conversation Laravel Guzzle Http Return Wrong Response

Hi guys, I'm facing a strange bug in laravel with Guzzle HTTP. I have 2 applications APP1 and APP2. The APP1 has to call APP2 by Guzzle HTTP to get data. I keep both projects in my localhost. When I call a URL in APP1, the action make a call to APP2 and return the response. But If we call through this way the application (APP2) uses the .env and database connections of APP1.

To confirm this I added the code in the action of the APP2.

return response()->json(['host' => DB::connection()->getConfig("host"), 'env_host' => env('DB_HOST')]); if I call the APP2 url directly on the browser, it return the correct result: {"host":"localhost","env_host":"localhost"}

But If I make a REST call over Guzzle HTTP from APP1 to APP2, it returns this response:

{"host":"localhostX","env_host":"localhostX"} localhostX is the value I added in .env file of APP2

This is the guzzle request code:

`` client = new Client([ 'base_uri' => 'http://localhost/app2/', 'http_errors' => true, 'allow_redirect' => true, ]);

        $response = $this->client->request('GET', $uri, []);

        $responseCode = $response->getStatusCode();
        $contentType  =  $response->getHeaderLine('content-type');
        $responseBody = $response->getBody()->getContents();
        dd($responseBody);

``

Can anybody have solution for this ?

Thanks

04 Apr
1 year ago

harit started a new conversation How To Authenticate Social Login From Back End For APIs

Hi, We have mobile app using Social Authentication. Once authenticated from andriod/iphone app they send a access_token and social_id to our laravel backend system. We think the backend system should validate the token and id with the corresponding social media sites. Like socialite plugin, do we have any plugins available for this? We need to validate the access token to Google, facebook and LinkedIn providers. I'm not sure this is the right method need to follow here. Any suggestion are appreciated.

Thanks,

31 Mar
1 year ago

harit started a new conversation How To Logout From Specific Device In Laravel Passport

Guys, I'm using Laravel passport for authenticating APIs for mobile app requests. As it is a small application, I don't need to use all stuffs on passport. I just used personalised tokens. After Installation, I created function to authenticate like this:

public  function login(Request $request)
    {
        $email = $request->get('email');
        $pwd   = $request->get('password');



        if(Auth::attempt(['email' => $email, 'password' => $pwd])) {

            $user = Auth::user();
            $token = $user->createToken('MyApp')->accessToken;

            return response()->json([
                'token' => $token
            ]);

        }
        else {
            return response()->json([
               'msg' => 'Unauthorized access'
            ]);
        }
    }

And In the log out function :

 public function logOut(Request $request)
    {

        Auth::user()->AauthAcessToken()->delete(); //where  AauthAcessToken is hasmany //relationship written in User.php to oauth_access_tokens table

        die('done');
        //dd(Auth::user());
    }
```````````````````````````````````````````````````````````````````````````

This works fine. But in my case what if we want to log out from specific device? Suppose user A has logined in mobile and Tab. now he want to log out from Tab only. If we call ``Auth::user()->AauthAcessToken()->delete(); `` all rows against that user_id will be deleted. Do we have any option to delete that particular row by using token from header bearer?
29 Mar
1 year ago

harit left a reply on Parameter Binding In Clause Inside WhereRaw

@bashy please see the question now. $aCandidate is the object of Candidate eloquent model class

harit started a new conversation Parameter Binding In Clause Inside WhereRaw

Hi,

in here is my query. I need to bind conditional params to my where clause.

...................................................................... $skillIds = 5,6,8; $aCandidate = $aCandidate->whereRaw("1 <= (select count(id) from candidate_skill where candidate_id = candidates.id AND candidate_skill.skill_id IN (?)", [$skillIds]); ...............................................

when I execute this query in my application. It didn't work as expected. But if I print the query and params and then run the raw sql in php myadmin I get results. I think there is something missed when I bind the params for IN clause. Anybody have any suggestions?

04 Mar
1 year ago

harit started a new conversation How To Send Parameters In Paginate Function

Hi, In one of the online project I have seen we can pass arguments in laravel paginator by this way. $aData->paginate($aRequest['rowCount'], ['*'], 'page', $aRequest['current']). But I didn't see any documentation regarding this. I checked the official documentation also, but not seeing such an implementation. Basically I need data table pagination (with out other plugins). So I need to get the total record count also. So by using paginate function I think I can implement in an effective way. Can anybody have any suggestion regarding this.

Thanks,

03 Mar
1 year ago

harit left a reply on Binding Params With Raw Query

That worked. thank you :)

harit started a new conversation Binding Params With Raw Query

I have a query for a paginated listing page. Some part of the SELECT and WHERE parts are raw queries. To avoid sql vularabilities, I need to use parameter binding for this query. It is worked for WhereRaw query where not worked in SELECT section.

Please see my query here:

$aJob = JobKeywords::where('job_keywords.status', 1) ->where('job_keywords.expiry_date', '>=', $today); whereRaw('MATCH(job_title,company_name,skills) AGAINST (? IN BOOLEAN MODE) > 0', [$keyword]) ->select(DB::Raw('job_keywords.job_id as job_id, ? as candidate_id, 1 as fts_search', [$candidateId]),"job_keywords.location as job_location_name", DB::raw('MATCH(job_title,company_name,skills) AGAINST (? IN BOOLEAN MODE) as score', [$keyword]), "job_keywords.company_name", "job_keywords.job_id as id","job_keywords.job_title", "job_keywords.skills", "job_keywords.expiry_date", "job_keywords.monthly_salary_range_min","job_keywords.monthly_salary_range_max", 'job_keywords.min_experience_in_year', 'job_keywords.metadata') ->orderBy('score', 'DESC') ->paginate(10)

The parameter binding in WhereRaw is working fine but inside Select(DB::Raw) not working. It will throw SQLSTATE[HY093]: Invalid parameter number error. If we dubug print_r($aJob->toSql()) and print_r($aJob->getBindings()) then you can see the parameter inside DB::raw is not counted.

Do any one have any idea about this?

Thanks in advance

25 Jan
1 year ago

harit started a new conversation Laravel View Not Updating In Some Browser

Hi, We are facing a strange but serious issue in Laravel view. We are using laravel paginator to display data in blade page. When we change the data in backend (through admin panel), it has to be reflect in our browser once reloaded the page. It is working fine in some systems where as this data changes are not reflecting in some other systems. We both using chrome browser. The only difference between us is we both are in different network IP address. If they use incognito window then they will be able to see the new data on their browser. Do the Laravel cache the data also along with blade template? Then why the issue happens in some systems only?. Do any one have any idea about it.

I have referred these docs and I'm sure my problem is not because of view caching by the laravel.

https://stackoverflow.com/questions/37503627/blade-view-not-reflecting-changes https://laracasts.com/discuss/channels/laravel/view-not-showing-changes

we use Laravel 5.4 version

06 Nov
1 year ago

harit left a reply on Repositories And Dependency Injection

@bobbybouwmann thanks, also, you mean we use repository to separate the logic from controllers, right? So we can write the repository logic anywhere in the project right? Like I can create new folder under app and write the logic there. There is no restrictions I think.

Also, can you please explain what is the advantage of the using class object from constructor argument rather than creating object inside class ?

harit started a new conversation Repositories And Dependency Injection

I have seen & used Repositories in laravel. But my question is what is the actual purpose of a Repository. Can we create Model classes for the same purpose (like in Zend). Do we have any advantage with it?

In most of the library codes we can see the Repository or a Model class is injected to the controller as constructor argument. Can anybody tell me what is the difference between these two code snippets?

use App\Repositories\MyRepo;

class MyController extends .. { protected $repo; public function __construct(MyRepo $repo) { $this->repo = $repo; }

}

AND

use App\Repositories\MyRepo;

class MyController extends .. { protected $repo; public function __construct() { $this->repo = new MyRepo; }

}

04 May
2 years ago

harit started a new conversation Which MySql Storage Engine Is Best With Laravel

Hi, I'm using MySql with Laravel 5.3. Can you please tell me which storage engine of MySql (InnoDB or MyISAM) can be used with Laravel for better performance.

Thanks, Hari

18 Mar
2 years ago

harit left a reply on Laravel SMTP Mail How To Add SSL Option

Is there any permanent solution for this? How we can get the ssl certificate and use mail with out editing vendor file?

02 Mar
2 years ago

harit left a reply on CURL Error 60: SSL Certificate Problem: Unable To Get Local Issuer Certificate

for wamp server, we need to update this php.ini (not from bin/php/php.ini)

(left click ) wampmanager icon -> PHP -> php.ini

14 Feb
2 years ago

harit started a new conversation ACL Implementation In Laravel 5.3

Hi, I would like to implement ACL in my application using Entrust or similar packages. I need to connect the route with the permission and then link this permission to roles. So when a user tries to access a route, we check its corresponding permission against that role. If I do this on every request, will the system become slow ? Or is that using any cache for storing and verifying the ACL data? Or can we use any alternative ways to accomplish this task?