anonymouse703

anonymouse703

Member Since 7 Months Ago

Experience Points 5,740
Experience Level 2

4,260 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 3
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

05 Apr
2 weeks ago

anonymouse703 left a reply on AJAX Doesn't Pass Data Even If Status Is 200

@jlrdw anad @snapey Sorry guys late reply I went to vacation for 1 almost a month.. I already configured the problem it's in the database storage....

19 Mar
1 month ago

anonymouse703 left a reply on Data Not Filtered Using WhereHas()

@FTIERSCH - Hi sir, I change the controller... I don't use the whereHas anymore I query the condition in with and it's working now.

$slc = Slclass::with(['child_sltype' => function ($query) use ($brcode) {
                            $query->where('SLTypeBR_CODE',$brcode);
                        }])
                        ->get();

anonymouse703 started a new conversation AJAX Doesn't Pass Data Even If Status Is 200

Hello guys I don't know what's the error. there's no error in Log file.. So here is the case... I used AJAX to update bulk of data.

This is my AJAX

function update_SL(){

    var sl = sl_records();
    var payload = { _token: '{{ csrf_token() }}', glcontrol:glcontrol, delete_glcontrol:delete_glcontrol }
    payload = $.extend(payload,sl)
    console.log(payload);
    return false;

  

    $.ajax({
      url: `/subsidiary/${brcode}/${slc}/${slt}/`,
      method: 'POST',
      headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
      data:JSON.stringify(payload),
      contentType: 'application/json; charset=utf-8',
      dataType: 'json',
       async: false,

      success: function(data){

              if(data.status == true){
                console.log(data);
                 //sreturn false;
                swal('Done!','Record successfully updated.', 'success');

                setTimeout(function(){
                  window.location.reload();
                }, 1000);

              }
              else if(data.status == false){

                swal({
                  title: "Oops!",
                  text: `Something went wrong please report this issue.`,
                  icon: "error",
                });

                setTimeout(function(){
                window.location.reload();
                }, 2000);

              }
            },/
            error: function(err){
              // console.log(err)
              alert(err.status);
              swal({
                title: "Oops!",
                text: `${err.message} sorry for this will fixed this soon.`,
                icon: "error",
              
              });
          }
        })
  }

This the console.log of the payload

{_token: "cTESOT53dMil3oqugYw8HyXg1cEkoonMovhgyVRq", glcontrol: Array(2), delete_glcontrol: Array(0), SLTypeBR_CODE: "1", SLTypeSLC_CODE: "11", …}SLTypeAI_FLAG_ar: "1"SLTypeAMORTYPE_ar: nullSLTypeAUID_FLAG_ar: "1"SLTypeAddOnIntSalesChargePay: "true"SLTypeBMBAL_SF_depo: ""SLTypeBR_CODE: "1"SLTypeCIAM_FLAG_ar: "1"SLTypeCIC_CONTYPID_ar: nullSLTypeCPAMO_FLAG_ar: "1"SLTypeDD_FLAG_ar: nullSLTypeDIMB_FREQ_ar: nullSLTypeDORM_PERD_depo: nullSLTypeDORM_SF_depo: ""SLTypeENCUMPCNT_ar: ""SLTypeFirstDueDateGP_ar: ""SLTypeINT_RATE_CODE_ar: ""SLTypeINT_RATE_ar: ""SLTypeINT_RATE_depo: ""SLTypeIPMT_MODE_ar: nullSLTypeIncludeChargePayment: 1SLTypeIsConsoPassbkPrinting: 1SLTypeIsConsoPassbkPrinting_depo: "1"SLTypeIsDisabled: 1SLTypeIsIncFO: 1SLTypeIsIncSOA: 1SLTypeIsTaxFree_depo: "1"SLTypeMAXBAL_depo: ""SLTypeMINCOMKR_ar: ""SLTypeMIN_BAL_depo: ""SLTypeM_DESC: "SAMPLE ONLy"SLTypeM_DESC2: "SAMPLE "cTESOT53dMil3oqugYw8HyXg1cEkoonMovhgyVRq"__proto__: Objectconstructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()

anonymouse703 started a new conversation Data Not Filtered Using WhereHas()

Hello guys I want to filter data by branch I implemented JQuery and AJAX but the data doesn't filtered..

Here is my AJAX..

 $('#select_branch').on('change', function() {
          // alert('click');
      let brcode = $('#select_branch').find(':selected').val();
      console.log(brcode);
      getSLByBranch(brcode)   
  });

  function getSLByBranch(brcode){
    $.ajax({
    url: `/sl-parents/${brcode}`,
    method: 'GET',
    success: function(data) {
        //console.log(data);
        dataHandles(data);    

      },
      error: function(e){
        console.log(e);
      }   

    });
  }

And my Controller is

$slc = Slclass::with('child_sltype')
                        ->whereHas('child_sltype', function ($query) use ($brcode) {
                            $query->where('SLTypeBR_CODE',$brcode);
                        })->get();

What I missed?

18 Mar
1 month ago

anonymouse703 started a new conversation Error: Undefined Variable: Brcode

I send the brcode using AJAX to filter data by branch.. but when I try to fetch the data I got this error Undefined variable: brcode"

This is my controller.

public function query($brcode) {

        $results = [];


        // $slc = Slclass::with('child_sltype')->get();
        $slc = Slclass::whereHas('child_sltype', function ($query) {
            $query->where('SLTypeBR_CODE',$brcode);
        })->get();
    
    return response()->json($results);
}
05 Mar
1 month ago

anonymouse703 left a reply on Reset Password Using 6 Or 8 Digits Of Code Instead Of Reset Link

You can changed the password in any length just set the code... don't use the re-setter just implement new one.

anonymouse703 left a reply on Selecting Model On Join With Count

Hello I think the error is in this line ->where('pending', '>', 0) is there pending column in your users table?

04 Mar
1 month ago

anonymouse703 left a reply on Cannot Save Avg Using UpdateOrCreate Method.

@MIRONMG - I just change everything and I used Left Join instead.. Thanks for the time sir.

03 Mar
1 month ago

anonymouse703 started a new conversation Cannot Save Avg Using UpdateOrCreate Method.

Hello everyone I cannot save avg in user table.. and there's no error in Log file.. What do I missed?

    public function changeRate(Request $request, $id){
        $rate = new Rating();
        $rate->user_id = $id;
        $rate->rating = $request->rating;
        $rate->save();

        $rateUser = DB::table('rating')
                ->where('user_id', $id)
                                ->avg('rating')
                                ->first();

        
         User::updateOrCreate(
                            ['id'=>$id],['rate'=>$rateUser]
                        );
    }
01 Mar
1 month ago

anonymouse703 left a reply on Cannot See The Relationship I Declared In My Model.

@MUNAZZIL - I rewrite all the relationship and it's working... I don't what has happened...

28 Feb
1 month ago

anonymouse703 left a reply on Cannot See The Relationship I Declared In My Model.

@MUNAZZIL - There's no migration table for it because we only use the old database... we just convert dos app to web app.

anonymouse703 left a reply on Cannot See The Relationship I Declared In My Model.

@SNAPEY - Hello sir, What I mean in my post is I declared the relationship in the controller but I didn't see it in the console..

anonymouse703 left a reply on Cannot See The Relationship I Declared In My Model.

@MUNAZZIL - I got an error "array_key_exists(): The first argument should be either a string or an integer" If I used belongsToMany

anonymouse703 started a new conversation Cannot See The Relationship I Declared In My Model.

Hello everyone, It was working before but now there's a problem..

I declared relation ship in my models.

SL MODEL

 public function child_sle(){
        return $this->hasMany('App\Glcontrol','GLControlSLE_CODE','SLE_TypeCode');
    }

GL model

 public function parent_glcontrol_sle(){
        return $this->belongsTo('App\Sle_type','GLControlSLE_CODE','SLE_TypeCode');
    }

and I have this in my controller.

$gl = Glcontrol::where('GLControlBR_CODE',$brcode)
                ->with('parent_glcontrol_br')
                ->with('parent_glcontrol_slc')
                ->with('parent_glcontrol_slt')
                ->with('parent_glcontrol_sle')
        ->get();

In my console There are data in

parent_glcontrol_br
parent_glcontrol_slc
parent_glcontrol_slt

But I didn't see the parent_glcontrol_sle.

What I missed?

19 Feb
2 months ago

anonymouse703 started a new conversation How To Attach Query Data From Model And Display It In View Per User?

Hello guys, how to attach query data from model to display in view per user?

I have a query here to get the average rating in my user model.

public static  function getRate($rate){
        
        $rateUser = DB::table('users')
                    ->join('rating', 'users.id', '=', 'rating.user_id')
                    ->select('users.*', DB::raw( 'AVG( rating.rating ) as ratings_average'))
                    ->groupBy('id')
                    ->orderBy('ratings_average', 'rating')
                    ->get();
        return $rateUser;            
        // dd($rateUser);
    }

This is the result +"ratings_average": 4.0

And I have something like this in my controller where the $rateUser will show to all users not individually... how to attached this per user in controller?

public function __construct(User $user)
    {
            $this->user = $user;
    }
        
    public function index(){
            // $users = User::all();
            $rateUser ='';
            $users = User::with('skills')
                            ->with('achievements')
                            ->with('rateDev')
                            ->get();
                            
            $skillsList = Skill::all();

            $rateUser = $this->user->getRate($rateUser);


        
        // dd($rateUser);
    
        return view('pages.dashboard.index')
            ->with('users', $users)
            ->with('rateUser',$rateUser)
            ->with('skillsList', $skillsList);
    }

Thank you and God bless.

18 Feb
2 months ago

anonymouse703 left a reply on How To Solve This? Undefined Offset: 0 (View:)

@SNAPEY - Already solved.. Thanks for the time sir.

anonymouse703 left a reply on The Page Has Expired Due To Inactivity.

@SAMUELNITSCHE - I just change the config session and env session to file...

anonymouse703 left a reply on How To Solve This? Undefined Offset: 0 (View:)

@KVITHALANI - I already solved it... my partner change some code in model.. that's why the error occurred... Thanks for the time...

I have new problem now..

refer to this : https://laracasts.com/discuss/channels/laravel/the-page-has-expired-due-to-inactivity-4

anonymouse703 started a new conversation The Page Has Expired Due To Inactivity.

Hello guys, I just updated my wamp and php version into newer version. My project was working before but when I tried it in the new wamp I cannot register or Login and there's an error.

The page has expired due to inactivity. 

Please refresh and try again.

Any idea what happened?

17 Feb
2 months ago

anonymouse703 started a new conversation How To Solve This? Undefined Offset: 0 (View:)

When I dd($users) I get some data.

Collection {#336 ▼
  #items: array:1 [▼
    0 => User {#330 ▼
      #fillable: array:11 [▶]
      #hidden: array:2 [▶]
      #connection: "mysql"
      #table: "users"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:21 [▶]
      #original: array:21 [▼
        "id" => 1
        "first_name" => "Jerome"
        "last_name" => "Villaver"
        "middle_name" => "Llacuna"
        "achievement_id" => null
        "country_id" => 1
        "provider" => "system"
        "avatar" => "avatar.png"
        "avatar_url" => null
        "email" => "[email protected]"
        "status" => 0
        "email_verified_at" => null
        "password" => "ykyU8Rcw3ZroKD2UV3r.0uj.Yilar30EMTyZ5PvOd.IT6WEwYoZ4q"
        "remember_token" => null
        "availabity" => null
        "address" => null
        "educaction_id" => null
        "notes" => null
        "rating_id" => null
        "created_at" => "2019-02-18 00:44:59"
        "updated_at" => "2019-02-18 00:44:59"
      ]

and my view is something like this

@foreach($users as $user)

{{$user->last_name}},{{$user->first_name}},{{$user->middle_name}}

@endforeach
14 Feb
2 months ago

anonymouse703 started a new conversation Homestead : Homestead.yaml Config

I'm just new in homestead...

What to put here if my projects are in D directoryD:\iaccs-admin-console

 - map: ~/code
      to: /home/vagrant/code

and I make a host file like this. 192.168.10.10 www.notification.test

and what should be the config on site part?

- map: homestead.test
      to: /home/vagrant/code/public
11 Feb
2 months ago

anonymouse703 left a reply on The Requested URL / Was Not Found On This Server.

@CRONIX - Yes... even when I hit localhost\phpmyadmin I can't access it.... I think my skype did the conflict...

10 Feb
2 months ago

anonymouse703 left a reply on The Requested URL / Was Not Found On This Server.

@SNAPEY - I got new observation... even my local host cannot be open...

http://localhost/phpmyadmin/

and I remembered I updated my skype last Friday afternoon... I think the Problem is in my skype and wamp port... but sad to say Skype cannot change the port as of now..

anonymouse703 left a reply on The Requested URL / Was Not Found On This Server.

@SNAPEY - Here's my setup in hhtpd.vhosts.conf and I don't use virtual machine...

<VirtualHost *:80>
    DocumentRoot C:/wamp64/www/notification/public
    ServerName www.notification.test
        <Directory "C:/wamp64/www/notification/public">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require local
        </Directory>
</VirtualHost>

anonymouse703 left a reply on The Requested URL / Was Not Found On This Server.

@JLRDW - just like that error when you tried to hit that route.

08 Feb
2 months ago

anonymouse703 left a reply on The Requested URL / Was Not Found On This Server.

@JLRDW - I make a virtual host before so that i will not run php artisan serve when i want to access my local program... It was running yesterday but when I open it this morning (here) it has some error (as mentioned above).

anonymouse703 started a new conversation The Requested URL / Was Not Found On This Server.

I don't if it's the right channel.. but If you help then Thanks.

I got an error when I put www.notification.test

Yesterday it was working but when I opened it today the error pop out...

The Error:

The requested URL / was not found on this server. Apache/2.4.27 (Win64) Server at www.iaccs-admin-console.test Port 80

I checked everything and it was okay but I can't figured out the error.. I tried the suggestions from google but doesn't work.

Thanks in advanced.

07 Feb
2 months ago

anonymouse703 left a reply on How To Click Button Inside In A Table Row In Modal?

@CRONIX - Yeah... don't worry about the id... just the click event...

06 Feb
2 months ago

anonymouse703 left a reply on How To Click Button Inside In A Table Row In Modal?

@CRONIX - Here's the scenario... I used AJAX to display all the values without change the page... and I have this modals for different category.

The button in the modal will show when there's data to append.

 //Show Skill
                    var itemsSkill = [];
                    var changeSkill = [];
                    $.each( data.skills, function(i, item) {
                        // console.log(item);

                    itemsSkill.push('<li>' + item.sklill_desc.description + '</li>');
                    changeSkill.push('<tr><td><input type="hidden" value="'+ item.id +'" class="skillID"><strong><li>'+ item.sklill_desc.description +'</li></strong></td><td><button class="btn btn-danger btn-sm delSkillButton"><i class="glyphicon glyphicon-remove"></i></button></td></tr>');

                    }); // close each()

                    $('#skill').append(itemsSkill.join(''));
                    $('#skillList').append(changeSkill.join(''));

see the class delSkillButton

then I have another function for delete.

 $('#SkillTable').on('click', '.delSkillButton', function(){
            
    var id = $('#skillTable').find('.SkillID').val();

            deleteSkill(id)
        });

        //delete Skill
        function deleteSkill(id){

            var id = $('.skillID').val();
            $.ajax({
            url: `/profile-skill-delete/${id}`,
            method: 'POST',
            data: {_token: '{{ csrf_token() }}'},
                success: function(data){
                    swal('Done!','Record successfully saved.', 'success')
                },
                error: function(err){
                    swal({
                    title: "Oops!",
                    text: `sorry for this will fixed this soon.`,
                    icon: "error",
                    });
                }
            });
        }

So that's thw whole code.

anonymouse703 left a reply on How To Click Button Inside In A Table Row In Modal?

@SNAPEY - There's no message or error.... I tried google too..

anonymouse703 left a reply on How To Click Button Inside In A Table Row In Modal?

@JLRDW - You can't use id if the button is in tr... it should use class..

05 Feb
2 months ago

anonymouse703 started a new conversation How To Click Button Inside In A Table Row In Modal?

How to click specific button in a table row inside a modal?

I made some script and didn't work..

I tried this code but not working

$('.delButton).on('click',function(){
    alert('click'); 
    var id = $('#SkillTable tbody tr.selected').find('input.skillID').val();
});

also this one.

 $('body').on('click','delSkillButton',function(){
    alert('click');
           var id = $('#SkillTable tbody tr.selected').find('input.skillID').val();
      
        });

Any help?

anonymouse703 left a reply on Is There Any Way On How To Get Desc From Another Table Using AJAX?

Solve. I just insert foreign key in each related table.

01 Feb
2 months ago

anonymouse703 started a new conversation Is There Any Way On How To Get Desc From Another Table Using AJAX?

Hello guys, How to get description from another table using AJAX?

When I tried this AJAX code I have an error

 data.skills.forEach(item => {
                     console.log(item);
                        $('#skill').append('<li>{{$skill->description->name}}</li>');
                    })

and my view is something like this.

@foreach($skill as $skill)
    <ul id="skill"></ul>
@foreach
31 Jan
2 months ago

anonymouse703 left a reply on Proper Code On UpdateOrCreate

My bad..... I have the wrong syntax... already solved.. This is the working one.

public function updateEducation(Request $request){
        
        $education = Education::updateOrCreate(
            ['user_id'=>Auth::user()->id],
            [
                'primary' =>$request->primary,
                'secondary' => $request->secondary,
                'tertiary' => $request->tertiary
            ]
        );
    }

anonymouse703 started a new conversation Proper Code On UpdateOrCreate

Hello guys, What should be the proper syntax using updateOrCreate method?

I got some error primary not defined

I have this code:

public function updateEducation(Request $request){
        return $request;
        
        $education = Education::updateOrCreate(
            ['user_id'=>Auth::user()->id],
            [
                'primary'=>$primary,
                'secondary'=>$secondary,
                'tertiary'=>$tertiary
            ]
        );
    }

'primary' is the field in my database.

Thank you.

21 Jan
3 months ago

anonymouse703 started a new conversation Err:NET_CONNECTION_TIMEOUT In Accessing Socket.js Server

Hello guys, When they try to listen to my app for notification they got an error err:NET_CONNECTION_TIMEOUT.

Here is my socket.js configuration.

When I tried to use this.

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();
redis.subscribe('notifications', function(err, count) {
});
redis.on('message', function(channel, message) {
    console.log('Message Recieved: ' + message);
    message = JSON.parse(message);
    io.emit(channel + ':' + message.event, message.data);
});
http.listen(3000, function(){
    console.log('Listening on Port 3000');
});

I have this result: Listening on Port 3000

but when I have this configuration.

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis');

server.listen(8080);

io.on('connection', function (socket) {
 
    console.log("New client connected: Port 8080");

    var redisClient = redis.createClient();
    redisClient.subscribe('message');

    redisClient.on("message", function(channel, message) {
        socket.emit(channel, message);
    });

    socket.on('disconnect', function() {
        redisClient.quit();
    });
 
});

I got nothing... it will just hang up.

13 Jan
3 months ago
12 Jan
3 months ago

anonymouse703 started a new conversation When I Test To Hit API Route Locally I Have A Return Data, But When In Production(online) It Can't Get Data... How To Solve It?

Hello everyone, I try to get data from API route in my online app but return null but when I tried to access my API route locally it will load data..

When I try to hit this in my local http://www.notification.test/api/notifications-get?app_code=iaccs

This will be the return:

[{"id":1,"app_code":"iaccs","data":"\"{data:'value'}\"","message":"New Update","custom_message":"Update notification sent","read_at":null,"created_at":"2019-01-12 07:23:10","updated_at":"2019-01-12 07:23:10"},{"id":2,"app_code":"iaccs","data":"\"{data:'value'}\"","message":"Nesdasda","custom_message":"Update nawala","read_at":null,"created_at":"2019-01-12 07:25:04","updated_at":"2019-01-12 07:25:04"},{"id":3,"app_code":"iaccs","data":"\"{data:'value'}\"","message":"New new","custom_message":"Update nawala","read_at":null,"created_at":"2019-01-12 07:27:05","updated_at":"2019-01-12 07:27:05"},{"id":4,"app_code":"iaccs","data":"\"{data:'value'}\"","message":"New errror","custom_message":"error","read_at":null,"created_at":"2019-01-12 07:30:09","updated_at":"2019-01-12 07:30:09"},{"id":5,"app_code":"iaccs","data":"\"{data:'value'}\"","message":"New errrorsssssss","custom_message":"error niiiii","read_at":null,"created_at":"2019-01-12 07:31:29","updated_at":"2019-01-12 07:31:29"},{"id":6,"app_code":"iaccs","data":"\"{test:'value'}\"","message":"sample message","custom_message":"sample custom message","read_at":null,"created_at":"2019-01-12 07:37:27","updated_at":"2019-01-12 07:37:27"}]

But when I hit in online (Production) http://35.246.184.134/api/notifications-get?app_code=iaccs

The result is Blank... There's no data.

How to solve it?

anonymouse703 left a reply on Uncaught ReferenceError: Auth Is Not Defined

@BOBBYBOUWMANN - Yeah I already changed it. Thanks sir.

10 Jan
3 months ago

anonymouse703 started a new conversation How To Notify Users To Different Application?

Hello everyone, Can I notify users from different app?

Ex. If the app1 send me a request data then I want to notify users to that specific application?

Flow:

Let say there are three application will send request data to me (notification app).

app1: Java (Loans) app2:Electron (Application Loan) app3: Laravel (Subscriber)

each application will send data to me (notification app) and I will restore it in notification table.

Example data:

Data from Loans

{
    "appCode": "Loans",
    "moduleId": "LoanProcess",
    "documentId": "{\"user\":2,\"client\":1453,\"refno\":132,\"recipients\":{\"users\":[1,2],\"roles\":[\"admin\",\"cashier\"],\"permissions\":[\"add-loan-profile\",\"add-loan-app\"]}}",
    "message": "New loan profile application",
    "customMessage": "New loan profile application of No name",
    "read": false
}

Data from Loans

{
    "appCode": "Application Loan",
    "moduleId": "LoanProcess",
    "documentId": "{\"user\":2,\"client\":1453,\"refno\":132,\"recipients\":{\"users\":[1,2],\"roles\":[\"admin\",\"cashier\"],\"permissions\":[\"add-loan-profile\",\"add-loan-app\"]}}",
    "message": "New loan profile application",
    "customMessage": "New loan profile application of No name",
    "read": false
}

Data from Subscriber

{
    "appCode": "Subscriber",
    "moduleId": "LoanProcess",
    "documentId": "{\"user\":2,\"client\":1453,\"refno\":132,\"recipients\":{\"users\":[1,2],\"roles\":[\"admin\",\"cashier\"],\"permissions\":[\"add-loan-profile\",\"add-loan-app\"]}}",
    "message": "New loan profile application",
    "customMessage": "New loan profile application of No name",
    "read": false
}

Now, I want to notify the specific user in each application (depend on appCode) ex. admin user. Is it possible?

So far what I've done is I created event and listener.

This is my current controller..

public function handle(Request $request){
        $data = $request->all();
        // \Log::info($data);
        $users = User::all();
       
        foreach ($users as $user) {
            $user->notify(new  newNotification($data));  
        }
        
        // \Log::info($user);

        event(new sendNotification($data));
    }

P.S I just created notification table using Laravel notification for testing only

anonymouse703 started a new conversation Uncaught ReferenceError: Auth Is Not Defined

My brain is under maintenance and I can't think normally right now.. I need some help with this error.

Uncaught ReferenceError: auth is not defined

this is my app.js

const app = new Vue({
    el: '#app',
    data: {
        notifications: ''
    },
    created() {
        axios.post('/notification/get').then(response => {
            this.notifications = response.data;

            console.log(response.data);
        });

        var userId = $('meta[name="userId"]').attr('content');
        Echo.private('App.User.' + userId).notification((notification) => {
            this.notifications.push(notification);
        });
    }
});

bootstrap.js

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
 
});

Should I put this in the bootrstrap?

    auth: {
         headers: {
            Authorization: 'Bearer ' + auth.token
         }
     }

anonymouse703 left a reply on How To Solve This Error: `app.js:38038 POST Http://www.notification.test/broadcasting/auth 403 (Forbidden)`

@D9705996 - I already did that one... And I don't know what to put in app.js and bootstrap.js

bootstrap.js:

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    wsHost: window.location.hostname,
    wsPort: 6001,
    disableStats: true,
  
});

Should I put this?

  auth: {
     headers: {
            Authorization: 'Bearer ' + auth.token
        }
    }

and this is my app.js

const app = new Vue({
    el: '#app',
    data: {
        notifications: ''
    },
    created() {
        axios.post('/notification/get').then(response => {
            this.notifications = response.data;

            console.log(response.data);
        });

        var userId = $('meta[name="userId"]').attr('content');
        Echo.private('App.User.' + userId).notification((notification) => {
            this.notifications.push(notification);
        });
    }
});

anonymouse703 left a reply on How To Make Event/lister For New Notification?

@VLAD_KASH - Yeah I already changed everything :) It is possible to notify the one who send the request?

For example.

Java application send a request into my Laravel app then I will store the request data in notification table. and iny my controller will be something like this :

$data = $request;
$user = $request->id;
$user->notify(new notification($data))

and how does other application will get the data from notification table?

anonymouse703 left a reply on How To Make Event/lister For New Notification?

@VLAD_KASH - Is my listener correct? My problem is that they want the owner of the request or the one who request will be notified through event/listener...