adityar15

Member Since 1 Year Ago

Experience Points
2,600
Total
Experience

2,400 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 your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
2,600 XP
Apr
09
1 week ago
Activity icon

Started a new Conversation Laravel Socialite Facebook Problem.

I am using Laravel socialite v5.0 which has Facebook graph api v3.3. Whenever I click facebook login button from my website it redirects to Facebook and displays

Sorry, something went wrong. We're working on getting this fixed as soon as we can.

I have implemented google login and it works well. Is there any issue with Graph API v3.3?

Activity icon

Replied to Getting 404 And 500 Error On Subdomain Occasionally

@wakanda Thanks for the reply. I figured out the problem. It was just the xampp thing. The app works perfectly on a live server. On xampp I have multiple domains configured that might be the reason for livewire to create conflict on subdomains.

Apr
08
1 week ago
Apr
02
2 weeks ago
Activity icon

Started a new Conversation Getting 404 And 500 Error On Subdomain Occasionally

I am using Livewire and Laravel to develop a multivendor application. Each vendor has a subdomain. When I run the project on a subdomain, it works well but in the middle of nowhere, I get errors 404 and 500 sometimes in a popup window. I checked the logs, the code everything seems ok. Not sure if I am missing any changes that Livewire requires for the subdomain?

Mar
20
4 weeks ago
Activity icon

Started a new Conversation Laravel Show UI According To Subdomain

I want to have a multitenant Laravel project where the main application resides on example.com while the SaaS application resides on subdomain.example.com. Each subdomain has a different UI.

I have created separate Laravel projects for now one for the main application and the other for subdomains. If I have to merge it into one application, how can I separate the request for example.com and subdomain.example.com?

Mar
14
1 month ago
Activity icon

Replied to Livewire Dom Diffing Issue For Pagination And Bootstrap Modal

@chaudigv Thanks for the answer. I tried all your ways but it didn't work.

However, I made it work with a bit of JavaScript. So bootstrap modal has event events and I was listening to the hidden.bs.modal event. On this event, I am hiding the modal again with javascript.

Something like this,

var hiddenflag=false;
window.addEventListener('hidden.bs.modal', ()=>{

var myModalEl = document.getElementById('myModal')
!hiddenflag ? myModalEl.hide() : window.removeEventListener('hidden.bs.modal', ()=>{})
hiddenflag=true;

});

It's an awkward solution but this the only one which worked.

Feb
27
1 month ago
Activity icon

Started a new Conversation Livewire Dom Diffing Issue For Pagination And Bootstrap Modal

So the problem is kind of a complex one. I have a list of items that I am fetching from the database with custom pagination. The reason for custom pagination is I need to call API through a livewire component.

In a blade file (normal view file) I have two livewire components

@livewire('items')
@livewire('modalcomponent')

<script>
    window.addEventListener('showmodal', () => {
        Livewire.emit('rendermodalcontent');
        
	var m = new bootstrap.Modal(document.querySelector('#modalid'), {
            keyboard: true
        })
     
    m.show()
    });
</script>

Each item has a button that triggers the bootstrap modal depending upon a condition. The bootstrap modal is in modalcomponent and the file looks something like this

<div class="modal fade" wire:key=modalid id="modalid" tabindex="-1" 
aria-labelledby="modalid" aria-hidden="true" wire:ignore.self>

//modal content

</div>


in my items component blade file, I have something like this

<div>

<div>
//some html

<button class='btn btn-danger' wire:click='triggermodal'>Trigger Modal</button>
</div>

<button class='btn btn-primary' wire:click='showmoreitems'>Show More</button>

</div>

In the controller file, the code looks like this,

class Items extends Component
{
    public $items=[] $lastpage=99999999999, $current=0, 
    $complete=false;


    public function render()
    {
        return view('livewire.items');
    }


    public function mount(){     
       $this->showmoreitems();
    }

public function triggermodal(){
	if($condition == true){
	$this->dispatchBrowserEvent('showmodal'); //defined in the view file
}
}

    public function showmoreitems(){
        $this->current += 1;
        if($this->current <= $this->lastpage)
        {
            $this->fetch();
        }
        else{
            $this->complete = true;
        }

    }



 public function fetch(){
       
        $this->dispatchBrowserEvent('loading');
        
        $take = 5;

        $datatosendapi                = [
            'page'    => $this->current,
            'take'    => $take,
        ];
	
	//api call


 $this->items =  array_merge($this->items, $response);


       


        $this->dispatchBrowserEvent('loading-complete');
    }



}

Now what's happening is when I load the page for the first time, the modal works fine. However, as soon as I fetch more items and trigger the modal for newly fetched items, the screen becomes dark grey (same as modal background) after I close the modal. The entire HTML does not respond to any clicks or events.

The modal has dynamic content loaded in it and it is rendered with new content every time it is triggered.

I am using Bootstrap 5.

Why is the modal is behaving weirdly? Am I missing something?

Thanks in advance :)

Feb
25
1 month ago
Activity icon

Started a new Conversation Does Livewire Component Routes Works Similar To Vue?

As in Vue, there is a router that renders only the required slot and not the entire page, is it the same with Livewire as well in case of the route being pointed to the Livewire component which is extended to the master layout?

Activity icon

Replied to How Does Laravel Session Works For Subdomains?

@corvs thanks for the answer. If that's so then I guess I do not need to make any changes as I want separate sessions for each subdomain.

Feb
07
2 months ago
Activity icon

Replied to SPA Application In Laravel 8

@mathewp did you manage to use turbolinks? Is it just all about including CDN in the master blade file?

Feb
03
2 months ago
Activity icon

Started a new Conversation How Does Laravel Session Works For Subdomains?

Suppose I have more than one subdomain (for simplicity 3) each pointing to the same Laravel project hosted on Elastic Beanstalk instance.

Now if someone logs in on domain abc.example.com and visits xyz.example.com, will the person share the same session status on both domains? For instance, say in the code in the menu there are lines in the blade file

@if(session('isloggedIn')

<li> Account </li>

@else 

<li> Login </li>

@endif

Now if person A logs in on abc.example.com, they will see Account in the menu. Now if the person visits xyz.example.com will they see Account or Login in the menu?

Thanks in advance :)

Jan
27
2 months ago
Activity icon

Replied to Multi Threading In Laravel

@chief_running_water thanks for sharing the link. I just used a walkaround for multithreading with some javascript and triggers. But this is something definitely to look on for future projects. Thanks for sharing it :)

Jan
21
2 months ago
Activity icon

Replied to Laravel Auth Showing Wrong User

So after spending hours and tons of search results I found a solution. I need to create an authentication process of my own. I replicated the logic of Laravel's authentication process of fetching the user and then matching credentials.

Activity icon

Replied to Laravel Auth Showing Wrong User

@hadayat That's all I could share. Actually, I have two users with the same email but different labels. And I am trying to get a second user but I am getting the first user details.

the line do some processing in the code is just fetching auth()->user()

 $details = [
        'label'=>'Customer', 
        'email'=>$request->email, 
        'password'=>$request->password, 
        ];


        if(Auth::guard('web')->attempt($details, $request->remember_me))
        {

$data = ['user'=>auth()->user()]
           

            return response()->json([
                'status' => 200,
                'data'   => $data
            ]);
        }

Activity icon

Replied to Laravel Auth Showing Wrong User

@hadayat Thanks for the reply. The label is required to authenticate.

Activity icon

Started a new Conversation Laravel Auth Showing Wrong User

I am trying to log in to the user using API. The API request is over curl as I am using Livewire.

The authentication works perfectly on a web app (the one having API code) but it does not work when called from another project. It shows the wrong user details instead of the authenticated user.

Here is the code

 $details = [
        'label'=>'Customer', 
        'email'=>$request->email, 
        'password'=>$request->password, 
        ];


        if(Auth::guard('web')->attempt($details, $request->remember_me))
        {

//do some processing
           

            return response()->json([
                'status' => 200,
                'data'   => $data
            ]);
        }


The array keys are exactly as per the database column. Could someone please help? What I am doing wrong?

Jan
15
3 months ago
Activity icon

Started a new Conversation Wire:loading For Scroll.

I am using pagination to show content on scroll. I am using livewire and while fetching the content I want to show loading on the frontend. I tried

<div wire:loading wire:target='fetch'>

'Getting content ...'

</div>

But it does not work. I am calling fetch function with an event.

<script>

window.addEventListener('load', ()=>{
	if(isinscrollview(document.querySelector('footer')){
	Livewire.emit('fetch')
}
});

</script>

Is there any best method to solve this? Thanks in advance :)

Activity icon

Replied to Laravel Cache

Thanks, @sergiu17 @chaudigv @mmanieri for the comments. I am following the approach of a unique cache key and it works perfectly.

Jan
13
3 months ago
Activity icon

Started a new Conversation Laravel Cache

Suppose if I have a function something like this

public function articles($author)

{

$articles = Cache::remember('articles', 1000, function () {
    return DB::table('articles')->where('author', $author)->get();
});

return views('articles')->with('articles', $articles);
}

If on live server say the first person hit the URL http://example.com/articles/2 where 2 is the id of the author or in other words $author=2

Now if the second person hits the URL http://example.com/articles/3 within 1000 seconds after the first person's visit, will the second person see articles from the author with id 2 as the cached results are for an author with id 2?

If I want to make it author specific, do I need to store different data in cache with unique keys like 'author'.$id?

Jan
11
3 months ago
Activity icon

Started a new Conversation Looking For Suggestion In Terms Of User Login

So I am working on a white label web application using Laravel and Livewire that has one backend code and server while different front end code as it will be different for each client (Whitelabel).

It will be having e-commerce functionality as well so I wanted a suggestion with regards to user login while checkout or keep it as the traditional method of checkout form filling.

As security is the prime feature, I thought user login might lead to potential security loopholes as the credentials are needed to be saved locally for every request.

Would anyone please suggest to me the correct approach to dealing with this problem? Thanks in advance :)

Jan
05
3 months ago
Activity icon

Replied to Livewire Events Are Not Fired

So finally got it working. For some weird reason, Livewire was not emitting the event because of the rendering issue. To get it working in my view file I need to emit a Livewire event to emit the event that I was actually looking for.

So I need to modify it somewhat like this


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    @include('common.head')
    @livewireStyles
    <link rel="shortcut icon" href='' id='title-logo'>
    <title>@yield('title')</title>
</head>
<body>

@livewire('menucomponent')

   


    @yield('content')

    @livewireScripts
    <script>

        window.addEventListener('load', ()=>{
            Livewire.emit('getassets');
        })
      
        window.addEventListener('changeassets', e=>{
          alert('loaded');
        });



    </script> 



</body>
</html>




The Controller is slightly changed as well

<?php

namespace App\Http\Livewire;

use Livewire\Component;

use App\Helper\apirequest;

class Menucomponent extends Component
{

    public $assets;
    
    public $response;

    protected $api;

    protected $listeners = [
        'getassets' => 'passtobrowser'
    ];

    public function render()
    {
        $this->api = new apirequest();
 

        $this->response = json_decode($this->api->apirequest(env('api_url')."getinfo/1",'GET'), true);


        $this->assets['color1']   = $this->response['data']['color1'];
    

        
        
        return view('livewire.menucomponent');
    }

    
    public function passtobrowser(){
        $this->dispatchBrowserEvent('changeassets', ['assets'=>$this->assets]);
    }



}



Activity icon

Replied to Livewire Events Are Not Fired

@vixo Thanks for the answer. I tried it and it still doesn't work.

Activity icon

Started a new Conversation Livewire Events Are Not Fired

I am trying to dispatch browser events in Livewire but strangely it is not being fired. Here is the code

Blade File


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    @include('common.head')
    @livewireStyles
    <link rel="shortcut icon" href='' id='title-logo'>
    <title>@yield('title')</title>
</head>
<body>

    @livewire('menucomponent')

   


    @yield('content')

    @livewireScripts
    <script>

        window.addEventListener('changeassets', event=>{
            alert('loaded');
        });


    </script> 



</body>
</html>

Here is my Livewire Controller FIle


<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Helper\subdomain;
use App\Helper\apirequest;

class Menucomponent extends Component
{

    public $assets, $response;
    

    public function render()
    {
        $this->api = new apirequest();


        $this->response = json_decode($this->api->apirequest(env('api_url')."getinfo/1",'GET'), true);

        $this->assets['color1']   = $this->response['data']['color1'];
              
        $this->dispatchBrowserEvent('changeassets', ['assets'=>$this->assets]);

     
        
        return view('livewire.menucomponent');
    }




}


Could anyone help, please? Thanks in advance :)

Dec
20
3 months ago
Activity icon

Started a new Conversation Sanctum Database Error

I am working on two separate web apps, App front and App back. Both are developed in Laravel with the only difference that App front is for front end and the other is for the backend.

The App front has livewire while App back has all the API endpoints with sanctum installed.

The issue is when App front makes an api request to App back, I am getting the following error

{"message": "SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `personal_access_tokens` where `personal_access_tokens`.`id` = 3 limit 1)"

I am making curl request from app front as it is in livewire.

The api works perfectly fine on postman. Also if I change the DB configurations on App front's .env file and make it same like App back, it works fine as well. I am testing these both on xampp server in my local environment.

Am I missing something as REST API are stateless and they do not need DB configuration on the front end side?

Thanks in advance :)

Dec
17
4 months ago
Activity icon

Replied to Laravel - Join To Get Result As A Nested Array

Hi @mirasmustimov

Currently, I am trying with a simple product and category relationship. I believe if this gets working then I could do others too.


//Categories.php

<?php

namespace App;

use App\Products;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Categories extends Model
{
    use HasFactory;
    protected $guarded = [];
    protected $table = 'tablename';

    public function products(){
        $this->hasMany(Products::class);
    }
}




// Products.php



<?php

namespace App;

use App\Categories;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Products extends Model
{
    use HasFactory;
    protected $guarded = [];
    protected $table = 'tablename';

    public function categories(){
        return $this->belongsTo(Categories::class,'fk', 'pk');
    }
}


I am getting two separate collections for the same categories. I am looking like all the products are listed under the same categories

Dec
15
4 months ago
Activity icon

Replied to Laravel - Join To Get Result As A Nested Array

@mirasmustimov thanks for the answer. I tried eloquent models but still, I am getting the same results. For each sub-attribute, I am getting different collection something like this"

[{id:1,
name:Phone,
atrribute:color,
subattribute: red
},
{id:1,
name:Phone,
atrribute:color,
subattribute: green
},
{id:1,
name:Phone,
atrribute:color,
subattribute: blue
},


Not sure if I am missing something

Dec
14
4 months ago
Activity icon

Started a new Conversation Laravel - Join To Get Result As A Nested Array

I am looking to construct a join query to join three tables namely table product, attribute and subattribute.

I want to have result as

{
id: 1,
name: Phone,
attribute: color,
subattribute: [red, green blue]
}


How should the join query look like?

Thanks in advance :)

Nov
19
4 months ago
Activity icon

Replied to Join For Multiple Foreign Keys Pointing To Same Primary Key

Perfect. This worked like charm. Thanks @michaloravec

Nov
17
5 months ago
Activity icon

Started a new Conversation Join For Multiple Foreign Keys Pointing To Same Primary Key

In my users table, I have a list of registered users and each user has different roles. For instance User A, B and C have role of X, Y and Z.

In another table, table Work, I am storing the id of these users. This id is a primary key in users table.

So my table Work has something like this


Workid | X_id | Y_id | Z_id
1            | 1      | 3      |  2

My Users table is something like this

id | Name      | Role
1  | Person 1 | X
2  | Person 2 | Z
3  | Person 3 | Y

What I am trying to achieve is on the front end I want to display in tabular format details of Work table which will have columns as

Workid, X name, Y name and Z name.

I am using DB Query builder and I tried join. It gives as I cannot use multiple separate joins with the same table.

How can I achieve the end result?

Thanks in advance :)

Nov
12
5 months ago
Activity icon

Replied to Redirecting A Subdomain To A Specific Url

@marianomoreyra I tried it but it did not work. I am getting error 500 and a message that there is a mistake in the configuration.

Nov
11
5 months ago
Activity icon

Replied to Redirecting A Subdomain To A Specific Url

Thanks for the answer @marianomoreyra I will try this out.

Activity icon

Started a new Conversation Redirecting A Subdomain To A Specific Url

I have a Laravel project on Elastic BeanStalk at domain https://www.example.com. Now I want to redirect a subdomain https://store.example.com to https://www.example.com/store but however, the URL in the browser would be https://store.example.com

Is it possible to do so? How can I achieve it? Thanks in advance :)

Nov
09
5 months ago
Activity icon

Replied to Laravel RESTful Shopping Cart

@filipkrstic I struggling with the same problem. Did you find a solution for yours?

Oct
28
5 months ago
Activity icon

Started a new Conversation How To Build White Label Laravel Application For The Existing One?

So I have a Laravel web app which is under our brand (logo, information on pages, etc.). We are planning to white label it a part of the web app. What would be the best way to do it?

I thought of having API endpoints developed in the main app and the white-labelled products talk with the main app using API. In this case, the issue would be with managing the cors.

Thanks :)

Oct
20
5 months ago
Activity icon

Replied to Livewire Not Making Any Ajax Requests?

Thanks @snapey. It worked for me. Just need to add a single parent element in one component. Forgot that every component of live wire is similar to Vue component where Vue has a template and here in Livewire it is one parent div or element.

Thanks again for the help :)

Activity icon

Replied to Livewire Not Making Any Ajax Requests?

I have the same problem for select wire:change. Did you find the solution to your problem @ollie_123

Oct
14
6 months ago
Activity icon

Replied to LinkenIn Login Using Socialite

@thewebartisan7 Thnks for the answer. I am an approved developer. I am trying to use r_basicprofile. Whenever I put scope a r_basicprofile, I receive an error code not found.

Activity icon

Started a new Conversation LinkenIn Login Using Socialite

I am using Socialite 5.* package for LinkedIn login. I want to get the vanity name of the user but as r_basicprofile is not supported, how can I get the vanity name?