mecjos

Member Since 3 Years Ago

İstanbul

Experience Points
4,120
Total
Experience

880 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
7
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
4,120 XP
Jan
16
2 days ago
Activity icon

Replied to Api Resource Collections As Argument In Event

:)) yeah fast beause I have been trying to solve that problem for 2 days. :) I have been waiting the anwer.. I try to make live data update when someone change the data. And all response should stay same, collection rosponse should be collection and etc.. because of frontside structure I can not send collection instead of resource object response. :) I hope it's not confusing :))

Activity icon

Replied to Api Resource Collections As Argument In Event

Thank you... second solution is good for me.. Even I pass collect((new JobController)->show($id))), I will need to check it's a JobResource or JobCollection.. I thought to do that by checking array or not :) that solution solved.. thanks again.

Activity icon

Replied to Api Resource Collections As Argument In Event

Thank you so much @marianomoreyra for your interest. Yes you are right, it's JobCollection resource when I fetch multiple record and JobResource for single record like below.. But foreach doesn't work for JobResource because I think JobResource cotains one resource object, in case JobCollection it contains collection array. I need to determine whether $updatedJobs contains collection or not.

When send broadcast(new JobUpdated((new JobController)->orderJobs($id)))->toOthers();

App\Http\Resources\JobCollection {#1745
  +collects: null
  +collection: Illuminate\Support\Collection {#1779
    #items: array:1 [
      0 => App\Job {#1784
        #fillable: array:12 [
          0 => "user_id"
          1 => "order_id"
          2 => "part_id"
          3 => "project_id"
          4 => "operation_id"
          5 => "queue"
          6 => "is_prior"
          7 => "state_id"
          8 => "finish_date"
          9 => "completed"
          10 => "is_combined"
          11 => "is_active"
        ]
        #casts: array:10 [
          "order_id" => "int"
          "part_id" => "int"
          "project_id" => "int"
          "operation_id" => "int"
          "state_id" => "int"
          "is_active" => "boolean"
          "is_prior" => "boolean"
          "is_combined" => "boolean"
          "queue" => "int"
          "completed" => "int"
        ]
        #connection: "mysql"
        #table: "jobs"
        #primaryKey: "id"
        #keyType: "int"
        +incrementing: true
        #with: []
        #withCount: []
        #perPage: 15
        +exists: true
        +wasRecentlyCreated: false
        #attributes: array:18 [
          "id" => 59
          "user_id" => 2
          "order_id" => 59
          "part_id" => 137
          "project_id" => 2
          "operation_id" => 1
          "state_id" => 4
          "queue" => null
          "completed" => 0
          "cost" => "0.00"
          "start_date" => null
          "finish_date" => null
          "pf_date" => null
          "is_prior" => 0
          "is_active" => 0
          "is_combined" => 0
          "created_at" => "2021-01-16 11:53:34"
          "updated_at" => "2021-01-16 11:53:48"
        ]
        #original: array:18 [
          "id" => 59
          "user_id" => 2
          "order_id" => 59
          "part_id" => 137
          "project_id" => 2
          "operation_id" => 1
          "state_id" => 4
          "queue" => null
          "completed" => 0
          "cost" => "0.00"
          "start_date" => null
          "finish_date" => null
          "pf_date" => null
          "is_prior" => 0
          "is_active" => 0
          "is_combined" => 0
          "created_at" => "2021-01-16 11:53:34"
          "updated_at" => "2021-01-16 11:53:48"
        ]
        #changes: []
        #dates: []
        #dateFormat: null
        #appends: []
        #dispatchesEvents: []
        #observables: []
        #relations: array:2 [
          "state" => App\State {#2044
            +timestamps: false
            #connection: "mysql"
            #table: "states"
            #primaryKey: "id"
            #keyType: "int"
            +incrementing: true
            #with: []
            #withCount: []
            #perPage: 15
            +exists: true
            +wasRecentlyCreated: false
            #attributes: array:3 [
              "id" => 4
              "color" => "red-12"
              "class" => "bg-red-12"
            ]
            #original: array:3 [
              "id" => 4
              "color" => "red-12"
              "class" => "bg-red-12"
            ]
            #changes: []
            #casts: []
            #dates: []
            #dateFormat: null
            #appends: []
            #dispatchesEvents: []
            #observables: []
            #relations: array:1 [
              "stateLang" => Illuminate\Database\Eloquent\Collection {#2053
                #items: array:2 [
                  0 => App\StateLang {#1787
                    +timestamps: false
                    #connection: "mysql"
                    #table: "state_langs"
                    #primaryKey: "id"
                    #keyType: "int"
                    +incrementing: true
                    #with: []
                    #withCount: []
                    #perPage: 15
                    +exists: true
                    +wasRecentlyCreated: false
                    #attributes: array:4 [
                      "id" => 7
                      "state_id" => 4
                      "lang_id" => 1
                      "name" => "İptal edildi"
                    ]
                    #original: array:4 [
                      "id" => 7
                      "state_id" => 4
                      "lang_id" => 1
                      "name" => "İptal edildi"
                    ]
                    #changes: []
                    #casts: []
                    #dates: []
                    #dateFormat: null
                    #appends: []
                    #dispatchesEvents: []
                    #observables: []
                    #relations: []
                    #touches: []
                    #hidden: []
                    #visible: []
                    #fillable: []
                    #guarded: array:1 [
                      0 => "*"
                    ]
                  }
                  1 => App\StateLang {#2041
                    +timestamps: false
                    #connection: "mysql"
                    #table: "state_langs"
                    #primaryKey: "id"
                    #keyType: "int"
                    +incrementing: true
                    #with: []
                    #withCount: []
                    #perPage: 15
                    +exists: true
                    +wasRecentlyCreated: false
                    #attributes: array:4 [
                      "id" => 8
                      "state_id" => 4
                      "lang_id" => 2
                      "name" => "Cancelled"
                    ]
                    #original: array:4 [
                      "id" => 8
                      "state_id" => 4
                      "lang_id" => 2
                      "name" => "Cancelled"
                    ]
                    #changes: []
                    #casts: []
                    #dates: []
                    #dateFormat: null
                    #appends: []
                    #dispatchesEvents: []
                    #observables: []
                    #relations: []
                    #touches: []
                    #hidden: []
                    #visible: []
                    #fillable: []
                    #guarded: array:1 [
                      0 => "*"
                    ]
                  }
                ]
              }
            ]
            #touches: []
            #hidden: []
            #visible: []
            #fillable: []
            #guarded: array:1 [
              0 => "*"
            ]
          }
          "project" => App\Project {#1791
            #fillable: array:8 [
              0 => "name"
              1 => "project_no"
              2 => "customer_id"
              3 => "user_id"
              4 => "cad3d_name"
              5 => "description"
              6 => "start_date"
              7 => "projected_finish_date"
            ]
            #casts: array:3 [
              "customer_id" => "int"
              "user_id" => "int"
              "active" => "int"
            ]
            #connection: "mysql"
            #table: "projects"
            #primaryKey: "id"
            #keyType: "int"
            +incrementing: true
            #with: []
            #withCount: []
            #perPage: 15
            +exists: true
            +wasRecentlyCreated: false
            #attributes: array:11 [
              "id" => 2
              "name" => "Şasi Deneme"
              "project_no" => "PRJ-03"
              "customer_id" => 3
              "user_id" => 2
              "description" => null
              "start_date" => null
              "projected_finish_date" => null
              "active" => 1
              "created_at" => "2020-12-22 18:52:45"
              "updated_at" => "2021-01-09 14:42:49"
            ]
            #original: array:11 [
              "id" => 2
              "name" => "Şasi Deneme"
              "project_no" => "PRJ-03"
              "customer_id" => 3
              "user_id" => 2
              "description" => null
              "start_date" => null
              "projected_finish_date" => null
              "active" => 1
              "created_at" => "2020-12-22 18:52:45"
              "updated_at" => "2021-01-09 14:42:49"
            ]
            #changes: []
            #dates: []
            #dateFormat: null
            #appends: []
            #dispatchesEvents: []
            #observables: []
            #relations: array:1 [
              "customer" => App\Customer {#2045
                #fillable: array:7 [
                  0 => "name"
                  1 => "address"
                  2 => "email"
                  3 => "phone"
                  4 => "ref_number"
                  5 => "parent_user_id"
                  6 => "user_id"
                ]
                #casts: array:3 [
                  "parent_user_id" => "int"
                  "user_id" => "int"
                  "active" => "int"
                ]
                #connection: "mysql"
                #table: "customers"
                #primaryKey: "id"
                #keyType: "int"
                +incrementing: true
                #with: []
                #withCount: []
                #perPage: 15
                +exists: true
                +wasRecentlyCreated: false
                #attributes: array:11 [
                  "id" => 3
                  "parent_user_id" => 2
                  "user_id" => 9
                  "name" => "Adinamik"
                  "address" => "null"
                  "ref_number" => "M001"
                  "email" => "[email protected]"
                  "phone" => null
                  "active" => 1
                  "created_at" => "2020-08-21 21:51:32"
                  "updated_at" => "2020-08-21 21:51:32"
                ]
                #original: array:11 [
                  "id" => 3
                  "parent_user_id" => 2
                  "user_id" => 9
                  "name" => "Adinamik"
                  "address" => "null"
                  "ref_number" => "M001"
                  "email" => "[email protected]"
                  "phone" => null
                  "active" => 1
                  "created_at" => "2020-08-21 21:51:32"
                  "updated_at" => "2020-08-21 21:51:32"
                ]
                #changes: []
                #dates: []
                #dateFormat: null
                #appends: []
                #dispatchesEvents: []
                #observables: []
                #relations: []
                #touches: []
                +timestamps: true
                #hidden: []
                #visible: []
                #guarded: array:1 [
                  0 => "*"
                ]
              }
            ]
            #touches: []
            +timestamps: true
            #hidden: []
            #visible: []
            #guarded: array:1 [
              0 => "*"
            ]
          }
        ]
        #touches: []
        +timestamps: true
        #hidden: []
        #visible: []
        #guarded: array:1 [
          0 => "*"
        ]
      }
    ]
  }
  +resource: Illuminate\Support\Collection {#1779}
  +with: []
  +additional: []
}

and when send broadcast(new JobUpdated((new JobController)->show($id)))->toOthers();

App\Http\Resources\JobResource {#1726
  +resource: App\Job {#1779
    #fillable: array:12 [
      0 => "user_id"
      1 => "order_id"
      2 => "part_id"
      3 => "project_id"
      4 => "operation_id"
      5 => "queue"
      6 => "is_prior"
      7 => "state_id"
      8 => "finish_date"
      9 => "completed"
      10 => "is_combined"
      11 => "is_active"
    ]
    #casts: array:10 [
      "order_id" => "int"
      "part_id" => "int"
      "project_id" => "int"
      "operation_id" => "int"
      "state_id" => "int"
      "is_active" => "boolean"
      "is_prior" => "boolean"
      "is_combined" => "boolean"
      "queue" => "int"
      "completed" => "int"
    ]
    #connection: "mysql"
    #table: "jobs"
    #primaryKey: "id"
    #keyType: "int"
    +incrementing: true
    #with: []
    #withCount: []
    #perPage: 15
    +exists: true
    +wasRecentlyCreated: false
    #attributes: array:18 [
      "id" => 57
      "user_id" => 2
      "order_id" => 57
      "part_id" => 137
      "project_id" => 2
      "operation_id" => 1
      "state_id" => 4
      "queue" => null
      "completed" => 0
      "cost" => "0.00"
      "start_date" => null
      "finish_date" => null
      "pf_date" => null
      "is_prior" => 0
      "is_active" => 0
      "is_combined" => 0
      "created_at" => "2021-01-16 00:55:55"
      "updated_at" => "2021-01-16 00:56:08"
    ]
    #original: array:18 [
      "id" => 57
      "user_id" => 2
      "order_id" => 57
      "part_id" => 137
      "project_id" => 2
      "operation_id" => 1
      "state_id" => 4
      "queue" => null
      "completed" => 0
      "cost" => "0.00"
      "start_date" => null
      "finish_date" => null
      "pf_date" => null
      "is_prior" => 0
      "is_active" => 0
      "is_combined" => 0
      "created_at" => "2021-01-16 00:55:55"
      "updated_at" => "2021-01-16 00:56:08"
    ]
    #changes: []
    #dates: []
    #dateFormat: null
    #appends: []
    #dispatchesEvents: []
    #observables: []
    #relations: array:2 [
      "state" => App\State {#1784
        +timestamps: false
        #connection: "mysql"
        #table: "states"
        #primaryKey: "id"
        #keyType: "int"
        +incrementing: true
        #with: []
        #withCount: []
        #perPage: 15
        +exists: true
        +wasRecentlyCreated: false
        #attributes: array:3 [
          "id" => 4
          "color" => "red-12"
          "class" => "bg-red-12"
        ]
        #original: array:3 [
          "id" => 4
          "color" => "red-12"
          "class" => "bg-red-12"
        ]
        #changes: []
        #casts: []
        #dates: []
        #dateFormat: null
        #appends: []
        #dispatchesEvents: []
        #observables: []
        #relations: array:1 [
          "stateLang" => Illuminate\Database\Eloquent\Collection {#2044
            #items: array:2 [
              0 => App\StateLang {#2053
                +timestamps: false
                #connection: "mysql"
                #table: "state_langs"
                #primaryKey: "id"
                #keyType: "int"
                +incrementing: true
                #with: []
                #withCount: []
                #perPage: 15
                +exists: true
                +wasRecentlyCreated: false
                #attributes: array:4 [
                  "id" => 7
                  "state_id" => 4
                  "lang_id" => 1
                  "name" => "İptal edildi"
                ]
                #original: array:4 [
                  "id" => 7
                  "state_id" => 4
                  "lang_id" => 1
                  "name" => "İptal edildi"
                ]
                #changes: []
                #casts: []
                #dates: []
                #dateFormat: null
                #appends: []
                #dispatchesEvents: []
                #observables: []
                #relations: []
                #touches: []
                #hidden: []
                #visible: []
                #fillable: []
                #guarded: array:1 [
                  0 => "*"
                ]
              }
              1 => App\StateLang {#1787
                +timestamps: false
                #connection: "mysql"
                #table: "state_langs"
                #primaryKey: "id"
                #keyType: "int"
                +incrementing: true
                #with: []
                #withCount: []
                #perPage: 15
                +exists: true
                +wasRecentlyCreated: false
                #attributes: array:4 [
                  "id" => 8
                  "state_id" => 4
                  "lang_id" => 2
                  "name" => "Cancelled"
                ]
                #original: array:4 [
                  "id" => 8
                  "state_id" => 4
                  "lang_id" => 2
                  "name" => "Cancelled"
                ]
                #changes: []
                #casts: []
                #dates: []
                #dateFormat: null
                #appends: []
                #dispatchesEvents: []
                #observables: []
                #relations: []
                #touches: []
                #hidden: []
                #visible: []
                #fillable: []
                #guarded: array:1 [
                  0 => "*"
                ]
              }
            ]
          }
        ]
        #touches: []
        #hidden: []
        #visible: []
        #fillable: []
        #guarded: array:1 [
          0 => "*"
        ]
      }
      "project" => App\Project {#2041
        #fillable: array:8 [
          0 => "name"
          1 => "project_no"
          2 => "customer_id"
          3 => "user_id"
          4 => "cad3d_name"
          5 => "description"
          6 => "start_date"
          7 => "projected_finish_date"
        ]
        #casts: array:3 [
          "customer_id" => "int"
          "user_id" => "int"
          "active" => "int"
        ]
        #connection: "mysql"
        #table: "projects"
        #primaryKey: "id"
        #keyType: "int"
        +incrementing: true
        #with: []
        #withCount: []
        #perPage: 15
        +exists: true
        +wasRecentlyCreated: false
        #attributes: array:11 [
          "id" => 2
          "name" => "Şasi Deneme"
          "project_no" => "PRJ-03"
          "customer_id" => 3
          "user_id" => 2
          "description" => null
          "start_date" => null
          "projected_finish_date" => null
          "active" => 1
          "created_at" => "2020-12-22 18:52:45"
          "updated_at" => "2021-01-09 14:42:49"
        ]
        #original: array:11 [
          "id" => 2
          "name" => "Şasi Deneme"
          "project_no" => "PRJ-03"
          "customer_id" => 3
          "user_id" => 2
          "description" => null
          "start_date" => null
          "projected_finish_date" => null
          "active" => 1
          "created_at" => "2020-12-22 18:52:45"
          "updated_at" => "2021-01-09 14:42:49"
        ]
        #changes: []
        #dates: []
        #dateFormat: null
        #appends: []
        #dispatchesEvents: []
        #observables: []
        #relations: array:1 [
          "customer" => App\Customer {#1791
            #fillable: array:7 [
              0 => "name"
              1 => "address"
              2 => "email"
              3 => "phone"
              4 => "ref_number"
              5 => "parent_user_id"
              6 => "user_id"
            ]
            #casts: array:3 [
              "parent_user_id" => "int"
              "user_id" => "int"
              "active" => "int"
            ]
            #connection: "mysql"
            #table: "customers"
            #primaryKey: "id"
            #keyType: "int"
            +incrementing: true
            #with: []
            #withCount: []
            #perPage: 15
            +exists: true
            +wasRecentlyCreated: false
            #attributes: array:11 [
              "id" => 3
              "parent_user_id" => 2
              "user_id" => 9
              "name" => "Adinamik"
              "address" => "null"
              "ref_number" => "M001"
              "email" => "[email protected]"
              "phone" => null
              "active" => 1
              "created_at" => "2020-08-21 21:51:32"
              "updated_at" => "2020-08-21 21:51:32"
            ]
            #original: array:11 [
              "id" => 3
              "parent_user_id" => 2
              "user_id" => 9
              "name" => "Adinamik"
              "address" => "null"
              "ref_number" => "M001"
              "email" => "[email protected]"
              "phone" => null
              "active" => 1
              "created_at" => "2020-08-21 21:51:32"
              "updated_at" => "2020-08-21 21:51:32"
            ]
            #changes: []
            #dates: []
            #dateFormat: null
            #appends: []
            #dispatchesEvents: []
            #observables: []
            #relations: []
            #touches: []
            +timestamps: true
            #hidden: []
            #visible: []
            #guarded: array:1 [
              0 => "*"
            ]
          }
        ]
        #touches: []
        +timestamps: true
        #hidden: []
        #visible: []
        #guarded: array:1 [
          0 => "*"
        ]
      }
    ]
    #touches: []
    +timestamps: true
    #hidden: []
    #visible: []
    #guarded: array:1 [
      0 => "*"
    ]
  }
  +with: []
  +additional: []
}
Jan
15
3 days ago
Activity icon

Replied to Api Resource Collections As Argument In Event

ok anyway.. thank you..

Activity icon

Replied to Api Resource Collections As Argument In Event

@bugsysha "dd(gettype($this->jobs)); put this at the top and report back what the result is." already did.. and I said it returns type object.

Activity icon

Replied to Api Resource Collections As Argument In Event

the problem is I can not check $this->jobs is array or not.. Because even I send an object array or single object to event argument its type returns object.

Jan
14
4 days ago
Activity icon

Replied to Api Resource Collections As Argument In Event

I think I send proper argument but I can't use it in event as I expect. Normally I get object array resposne from jobOrders method.. I expect an array like its http response. There is a point about event that I miss.

Activity icon

Replied to Api Resource Collections As Argument In Event

@bugsysha that didn't work also.. I will be give full code path to make it more understandable..

broadcast(new JobUpdated((new JobController)->orderJobs($id)))->toOthers(); // sending a controllers method as argument to JobUpdated event
public function orderJobs ($orderId) {
        $orderJobs = Job::with($this->with)->where('order_id', $orderId)->get();
        return new JobCollection($orderJobs);
    } // returns JobColleciton 
    public function broadcastOn()
    {

        $channels = [];
        if (is_array(collect($this->jobs))) { // it must be an array but goes into else state.. 
            foreach ($this->jobs as $job) {
                $order = Order::find($job->order_id);
                $userId = Machine::find($order->machine_id)->operator->user->id;
                array_push($channels, new PrivateChannel('Job.' . $userId));
            }
        } else {
            $order = Order::find($this->jobs->order_id);
            $userId = Machine::find($order->machine_id)->operator->user->id;
            array_push($channels, new PrivateChannel('Job.' . $userId));
        }
        // todo: when managers roles created, manager user ids will be added to channels..
        return $channels;
    }
Activity icon

Replied to How To Auto Submit A Form In By Clicking The Checkbox Without Page Reload

You can create a vue component for your form and then handliing the on change event you can set the isActive data..

	<input type="checkbox" checked v-on:change="changeStatus()"/>
<script>
import axios from 'axios'..
 export default {
	data () {
		return {
			isActive = false
		}
	}
	methods: {
		changeStatus () {
			return new Promise() ... make server request
			.then() ... set isActive status according to response.
		}
	}
}
</script>
Activity icon

Replied to Api Resource Collections As Argument In Event

@bugsysha api resource collection class is already returning an array:

public function toArray($request)
    {
        return parent::toArray($request);
    }

when I add ->toArray() method it wants $request argument.. actually it must return an array already but in event it looks like object.

Activity icon

Started a new Conversation Api Resource Collections As Argument In Event

Hi.. I want to broadcast an api resource collection (sometimes only resource) and I send it to event as argument

broadcast(new JobUpdated($jobsCollection)->toOthers();

In event class I want to do something like below :

 use Dispatchable, InteractsWithSockets, SerializesModels;
    public $jobs;
    public $TypeOfJobsVariable;

    public function __construct($updatedJobs)
    {
        $this->jobs = $updatedJobs;
        $this->TypeOfJobsVariable = gettype($this->jobs);
    }

    public function broadcastOn()
    {
        $channels = [];
        if (is_array($this->jobs)) {
            foreach ($this->jobs as $job) {
                $order = Order::find($job->order_id);
                $userId = Machine::find($order->machine_id)->operator->user->id;
                array_push($channels, new PrivateChannel('Job.' . $userId));
            }
        } else {
            $order = Order::find($this->jobs->order_id);
            $userId = Machine::find($order->machine_id)->operator->user->id;
            array_push($channels, new PrivateChannel('Job.' . $userId));
        }
        return $channels;
    }

when I check the type of $this->jobs it's object it's object both $this->jobs is collection and just single record.

How Can I make this foreach loop in event?

Jan
11
1 week ago
Activity icon

Replied to Route::get Doesn't Work When Same Name With Resource Route

@marianomoreyra anyway.. your answer fixed my problem.. thanks .. )

Activity icon

Replied to Route::get Doesn't Work When Same Name With Resource Route

Hi @marianomoreyra , thanks for your fast reply.. sorry Actually I expressed my problem wrong. :) Actually I figured it out right now...) I shoud have inserted {orderId} into Route::get.....

When new route added like

Route::get('jobs/allJobs', 'Api\[email protected]')

Even full route is different it refers to index() method of controller because {id} argument wasn't determined. Is there a solution for this situation.

Activity icon

Started a new Conversation What Are The Differeneces Between Api Resource Response And Http Response

I wonder what are the main logic behind api resources except adding meta data to response.. And what are the differences between api resource collections and http json responses. I get same response when I get http json response by returning

return response()->json($model, 200)

with by returning

$jobModel;

return new JobResource($jobModel);

Where can I find usage examples and best practices for api resource collections?

Activity icon

Started a new Conversation Route::get Doesn't Work When Same Name With Resource Route

Hi. I have an interesting problem with routes or it's not a problem which I couldn't understand the reason .. When I have a Resource route as follows :

Route::apiResource([
	'jobs' => 'Api\JobController'
])

I can't give same root path name for new Route:get for new methods I created in JobController like example below;

JobController:

public function orderJobs($orderId) {
.
.
.
}

When I add the route below. It doesn't work..

Route::get('jobs/orderJobs', 'Api\[email protected]');

If change the root path name from 'jobs' to 'job' I mean change it. It works. But for Route::post method, I can use same root path name.

What is that's reason ??

Jan
09
1 week ago
Activity icon

Replied to Set Veux Module State From Root Mutation

that works when I try to change from root... thank you.. how can I do it from module mutation..

Jan
02
2 weeks ago
Activity icon

Replied to Set Veux Module State From Root Mutation

I want to change a vuex modules state from another module's mutation..

Jan
01
2 weeks ago
Activity icon

Started a new Conversation Set Veux Module State From Root Mutation

Hi. I want to set a module's state from root mutation something like as follows:

mutation in root store folder:

export function SET_CONTENT (state, payload) {
  state.someModule.list = payload.data
}

How can i do it?

Thank you.

Dec
19
4 weeks ago
Activity icon

Replied to Querybuilder Problem On HasManyThrough Relation

@michaloravec thanks. that worked.. Normally it's not needed.. Is it because there are three tables?

Activity icon

Started a new Conversation Querybuilder Problem On HasManyThrough Relation

Hi.. I have some problem on making query on a hasManyThrough relaton. When I add where condition on that relation I get sql error. My code and error is as follows:

Machine::where('user_id', Auth::user->parent_user_id)->with(['jobs' => function ($query) {
            $query->where('is_active', 1)->with('part.image', 'part.cads', 'project.customer', 'state.stateLang');
        }, 'operator.image'])->get();

problematic part on code is :

->with(['jobs' => function ($query) { $query->where('is_active', 1)

when I add that where condition I get following error:

"message": "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'is_active' in where clause is ambiguous (SQL: select jobs.*, orders.machine_id from jobs inner join orders on orders.id = jobs.order_id where orders.machine_id in (6, 7, 8, 9) and is_active = 1)"

How Can I make where condition on that jobs relations? Thank you.

Dec
12
1 month ago
Activity icon

Replied to Using Eloquent Models In Notification

@marianomoreyra thank you.. But I couldn't understand why chaining order is important..

Activity icon

Started a new Conversation Using Eloquent Models In Notification

Hi, I want to use some eloquent models in notification to add additional data into mail or broadcast noti... When I add eloquent models as follows I get "You cannot serialize or unserialize PDO instances" error. How Can I do this?

   public $job;
   public $order;
   public $part;
   public $operation;

public function __construct($job)
   {
       
       $this->job = $job;
       $this->order = Order::find($this->job->order_id);
       $this->part = Part::find($this->job->part_id);
       $this->operation = Operation::find($this->job->operation_id)->with('operationLang');
   }

Nov
29
1 month ago
Activity icon

Replied to Authentiaction With A Url In E-mail?

@vixo I have several user roles and I want some roles can reach without sign-up. Some users already must authanticate with password grant. I will try it. Thank you.

Activity icon

Replied to Authentiaction With A Url In E-mail?

@vixo thank you.. It seems like it's for my case but I couldn't understand from doc. Can I use it with laravel passport. I don't want to break laravel passport structure.

Activity icon

Started a new Conversation Authentiaction With A Url In E-mail?

Hi. I want some of my app users to sign in for some pages without sign up. To do this I want to use a specifica link in email for user. Is there a way to do that with laravel passport ?

Thank you.

Nov
25
1 month ago
Activity icon

Awarded Best Reply on How To Install New Packages On Godaddy Shared Hosting

Problem solved.. When new package uploaded, composer dump-autoload must be run and uploaded composer folder also..

Activity icon

Replied to How To Install New Packages On Godaddy Shared Hosting

Problem solved.. When new package uploaded, composer dump-autoload must be run and uploaded composer folder also..

Activity icon

Replied to How To Install New Packages On Godaddy Shared Hosting

@martinbean thanks for your reply.. I can run queue work and other artisan commands on godaddy shared hosting and composer is installed on my host but there is something wrong I can't understand.

I already tried to uplaod files from local. I uploaded barryvdh/laravel-dom and domPdf folders as well as app.config file for Service provider configuration. But in this case, I get service provider couldn't find error. Is there anything else that I should do.

Activity icon

Started a new Conversation How To Install New Packages On Godaddy Shared Hosting

Hi. I'm using godaddy shared hosting to test my app. How can I install new packages in proper way on godaddy shared hosting. When I try to install it by using ssh connection but while updating dependancey it says killed on terminal. Composer.json file is updated but there is nothing in vendor folder. I want to install laravel domPdf. Besides I tried to upload vendor/barryvdh and dompdf folder from dev to prod directly, this time it gives 'serviceprovide couldn't find' error.

Nov
22
1 month ago
Activity icon

Started a new Conversation Accessing Object Property With Another Object Property Value

Hi. I want to an ojbect property value as another object property name as follows;

object = {
quantity: 4,
color: green
}

object2 = {
attribute: quantity
}

object.(object2.attribute), => 4   // something like that.

How can I do it?

Nov
17
2 months ago
Activity icon

Replied to Vue Reactivity Problem

thanks for your interest.. it was backend based problem, I solved it. thanks again.

Activity icon

Replied to Vue Reactivity Problem

Ok thank you.. That didn't work neither. :( This stackoverflow example about updating vuex state.. I know that situation. Vuex states must be defined only in mutations. In my case there is no problem about updating pageContent. When I use pageContent in table's data property it updates I mean reactivity works but when I use filterParts it doesn't.. There is a problem in filterPart computed property.

Activity icon

Replied to Vue Reactivity Problem

ok. I will give details... if you can help I will be glad.

Table:

<q-table :data="filterParts" :columns="tableColumns" row-key="id" selection="multiple" :selected.sync="selectedItems"
                       :pagination.sync="pagination">

Data and computed properties which I used for table:

<script>
import { mapState } from 'vuex'

  data () {
    return {
      selectedAssembly: null,
      },
computed: {
    ...mapState(['pageContent', 'partAssemblies']),
    filterParts () {
      return this.pageContent.filter(part => {
        if (part.assemblies && part.assemblies.length > 0) {
          return part.assemblies[0].id === this.selectedAssembly
        }
      })
    }

When I add new part following mutation is triggered and updates pageContent state:

export function UPDATE_PAGE_CONTENT (state, payload) {

    state.pageContent.push(payload.data)

}

which part is problematic

Activity icon

Replied to Vue Reactivity Problem

I add same method.. only difference is filterPart computed property. When change :data property to pageContent, when it's updated table updated. Normally I expect pageContent's content updated, filterParts computed property must update table data..

Activity icon

Started a new Conversation Vue Reactivity Problem

Hi. I have some problem about reactivity I think. I use quasar framework for my job tracking app. I have a parts table and a assembly tree to filter parts. When I use computed property to filter table data, when new part added it doesn't update table content.. Filter function break the reactivity as far as I understood. Let me explain with codes :

Quasar data table:

<q-table :data="filterParts" :columns="tableColumns" row-key="id" selection="multiple" :selected.sync="selectedItems"
                       :pagination.sync="pagination">

Here is my page content which I get from mapState and filter computed property:

..mapState(['pageContent', 'partAssemblies']),
filterParts () {
      return this.pageContent.filter(part => {
        if (part.assemblies && part.assemblies.length > 0) {
          return part.assemblies[0].id === this.selectedAssembly
        }
      })
    }

When I choose an assembly it must filter table.. It filters table well but when I add new part to table it doesn't update. If I put pageContent directly table's data property, it updates when I add new part. Why that filter function break the reactivity? When added new part, I check vuex state and new part added into state.

Thank you.

Oct
31
2 months ago
Activity icon

Started a new Conversation Homestead VirtualBox Error

Hi. I'm trying to install homestead.. I installed everything according to documentation. At vagrant up step I got following error:

There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "9b6dd232-b218-4bcd-a91c-4920fd150d18", "--type", "headless"]

Stderr: VBoxManage.exe: error: Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

Hyper-V is enabled and virtual machine is enabled from BIOS

Oct
26
2 months ago
Activity icon

Replied to Filtering Objcet Array In An Object Array

@sinnbeck

Ok, it worked. Thank you again..

Activity icon

Replied to Filtering Objcet Array In An Object Array

@sinnbeck I mean I need to perform filtering on a copy of operations object array.

Activity icon

Started a new Conversation Filtering Vuex State Without Changing It

Hi. I want to filter an object array in my vuex store. I use following logic but it changes state itself also. How can I do that without filtering state itself.

computed : {
      ...mapState(['pageContent']),
      filteredOrders () {
        console.log(this.history)
        return this.pageContent.map(operation => {
          operation.orders = operation.orders.filter(order => {return order.is_active === this.history})
          return operation
        })
      }
    },
Activity icon

Replied to Filtering Objcet Array In An Object Array

@sinnbeck I have another problem with this.. I filter a vuex state with this computed property.. This filter function changes vuex state variable also.. How can i filter and assign it into new variable without changin state.

Oct
25
2 months ago
Activity icon

Replied to Filtering Objcet Array In An Object Array

oh thank you.. I tried same logic but forgot to return item again. :) thanks...

Activity icon

Started a new Conversation Filtering Objcet Array In An Object Array

Hi. I have following object array;

operations = [
{
id: 1, 
description: 'aldjfl', 
orders: [
{id:1, is_sent:0, is_active:0},
{id:2, is_sent:1, is_active:1},
..
..
..
]
}
{id:2, description: 'ajlsf', orders: [{},{}....]'}
]

I want to only to filter orders array accordinto is_active property in my operations object array. I couldn't find a proper solution. I need help.

Oct
21
2 months ago
Activity icon

Started a new Conversation Send Database Notification Record As Push Notification

Hi. I want to send recorded notification into database as push notification. Because I want to add notification to my notifications store array. They must be in same structure..

public function toArray($notifiable)
    {
        return [
            'message' => 'notification message',
            'route' => 'orders',
            'user' => $notifiable
        ];
    }

this returns as push notification but my database record has also created_at and read columns.. When I get notification I can not push it into notifications store state at my front side.

Oct
14
3 months ago
Activity icon

Replied to Laravel Appended Accessor Causes Slow Response

It's already eager loading but very slow again.anyway, It seems I will need to remove appended accessor.. Thanks all..

Activity icon

Replied to Laravel Appended Accessor Causes Slow Response

@snapey thanks for your advice.. but I already know which part of code makes slow my response.. I look for a solution for that.. If you know a solution please help... I debugged it already by myself.. It's obvious that appended accessor with relation is problematic..

Activity icon

Replied to Laravel Appended Accessor Causes Slow Response

My app is vue spa and my laravel is an api server.. I guess I can't use debugbar directly for my app.. I don't want to make complecated arrangements for debugging. If you know that problem because of too many query and my usege of appended accessors, could you give alternative solution if you know please?

Oct
12
3 months ago
Activity icon

Replied to Laravel Appended Accessor Causes Slow Response

When I remove appended accessor from model it works normal.. Might be a problem on my appended accessor? I don't think it's because of too many queries.

Oct
11
3 months ago
Activity icon

Started a new Conversation Laravel Appended Accessor Causes Slow Response

Hi. An appended accessor makes very slow the response (about 30 seconds.).. I'll try to explain with codes below..

My problematic eloquent model is :

$machines = Machine::where($condition)->with(['jobs' => function ($query) { $query->orderBy('queue', 'asc');
    },'jobs.part.image', 'jobs.project.customer', 'jobs.state.stateLang', 'operator.image'])->get();

eager loaded project relation in my model jobs.project.customer has appended accesssor as follow:

Project Model:

    protected $appends = ['stats'];

    public function getStatsAttribute()
     {
         return (new ProjectController)->stats($this->id);
     }

I use that attribute to attach project progress for every project record. Actually I don't need that in my problematic collection but it gets. And my function in which I calculated stats is as follow:

public function stats($id)
{
    $totalJobs = 0;
    $totalCompletedJobs = Job::where('project_id', $id)->where('state_id', '!=', 4)->sum('completed');
    foreach (Job::where('project_id', $id)->where('state_id', '!=', 4)->cursor() as $job) {
        $part = Part::find($job->part_id);
        $totalJobs = $totalJobs + $part->quantity;
    }
    return ['totalJobs' => $totalJobs, 'totalCompletedJobs' => (int)$totalCompletedJobs];
}

Is that method wrong to get stats in that appended attribute way? Besides, actually I don't need project stats in that $machine collection, when getting project.customer relation it takes that accessor also. How Can I do that in correct way? Can I cancel appended attribute for once for any query?

Edit: Additionally, this works very fast (around 300ms) on localhost. On shared server it takes about 30 seconds. Is that difference in possible range?

Oct
10
3 months ago
Activity icon

Replied to Too Long Response Time

I tried clockwork.. I found the exact part of code to cause slowness.. Wrote above.. Now my question changed.. Whey appended attribute makes it slow? Is that wrong way ?