mecjos

Member Since 3 Years Ago

İstanbul

Experience Points
5,130
Total
Experience

4,870 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
9
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 2
5,130 XP
May
08
15 hours ago
Activity icon

Replied to Laravel Personal Access Client

If multiple personal access token is created, how to create personal access token by client id?

May
07
1 day ago
Activity icon

Replied to Authentiaction With A Url In E-mail?

Hi, I tried to make something with creating personal access client. Could you check my following questions if you can help I will be glad.. thank you.

https://laracasts.com/discuss/channels/laravel/put-route-deosnt-work-with-custom-api-guard-passport

Activity icon

Started a new Conversation How To Create Personal Access Token By Client Id

Hi. I have two personal access clients for two different model and I want to create personal access token by determining client id ? How can I do that? And while creating persoal access client by php artisan passport:client --personal command it doesn't ask which provider will be used. I have two personal access client and I want to use different providers for them. Is there a way to set provider while running client creation command? I use laravel 8. Thank you.

Activity icon

Started a new Conversation PUT Route Deosn't Work With Custom Api Guard (Passport)

Hi. I have a personal access client to produce access tokens for my manufacturers and customers tables. And added provider and api-guarda as follows;

Providers in auth/config

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],
        'customers' => [
            'driver' => 'eloquent',
            'model' => App\Models\Customer::class,
        ],
        'manufacturers' => [
            'driver' => 'eloquent',
            'model' => App\Models\Manufacturer::class,
        ]
    ],

Guards:

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],

        'api-customer' => [
            'driver' => 'passport',
            'provider' => 'customers',
            'hash' => false,
        ],

        'api-manufacturer' => [
            'driver' => 'passport',
            'provider' => 'manufacturers',
            'hash' => false,
        ],
    ],

And added hasApiTokenclass into related models. I added that client's routes as follows:

Route::middleware('auth:api-manufacturer')->group(function () {
    Route::get('jobs/outsource/{orderId}', '[email protected]');
    Route::get('outsource/states', '[email protected]');
    Route::get('outsource/cad/{id}', '[email protected]');
    Route::get('job/stateupdate/{id}','[email protected]');
});

The problem is when I add put route in order to update record it retruns unauthanticated error. Only get routes are working but when I check routes with php artisan route:listcommand I can see routes in correct way. Where is the problem? Why that new api guard doesn't work like predefined api:auth guard? Thank you.

May
02
6 days ago
Activity icon

Replied to Redirect Not Authanticated User

I got following error with the solution you said.

ErrorException: Header may not contain more than a single header, new line detected in file /home/vagrant/code/vendor/symfony/http-foundation/Response.php on line 359

First it worked but now I get this error.

Apr
24
2 weeks ago
Activity icon

Replied to How To Get Token Via Authorization Code Grant With PKCE

this is not Authorization Code Grant with PKCE..

Activity icon

Started a new Conversation Redirect Not Authanticated User

Hi, I am using laravel passport for authantication for my api. When not authanticated request was made to a route, it redirect to login route because of authanticate middleware.

 protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('/login');
        }
    }

but as far as I know that route is for web routes.. Normally request is api request but it tries to redirect to web route. I want to its give a 'authantication is needed' message response. Where is the problem? Thank you.

Activity icon

Started a new Conversation How To Get Token Via Authorization Code Grant With PKCE

Hi, I'm trying to get access token via code grant as described in doc. I want to get token in a controller programatically. But it doesn't create accesstoken, my logic is below,

Controller which creating oken:

public function getCode (Request $request) 
    {
        session()->put('state', );
        $state = Str::random(40);
        $code_verifier = Str::random(128);

        $codeChallenge = strtr(rtrim(base64_encode(hash('sha256', $code_verifier, true)) , '='), '+/', '-_');

        $query = http_build_query([
            'client_id' => 3,
            'redirect_uri' => 'http://192.168.10.10/api/customers',
            'response_type' => 'code',
            'scope' => '',
            'state' => $state,
            'code_challenge' => $codeChallenge,
            'code_challenge_method' => 'S256',
    ]);

        return redirect('http://192.168.10.10/oauth/authorize?'.$query);
    }

I am expect its to create access token through http://192.168.10.10/oauth/authorize?'.$query url and redirect to http://192.168.10.10/api/customersbut since it didn't create access token it gives login route not defined error.

How can i get access token with this?

Apr
23
2 weeks ago
Activity icon

Replied to How To Make Passwordless Authentication With Passport

@jlrdw I think my question is not clear or you didn' read my question :) I already read all of that docs. But I couldn't find a solution for logining in wihout password except magiclink package. Because I don't want to use external package for that I think it is solvable with laravel passport. Thanks anyway.

Activity icon

Started a new Conversation How To Make Passwordless Authentication With Passport

Hi everyone. I want to make authentication without password with laravel passport. I have users, customers and employes models in my app and only users model loging in by using username and password. I want to send an authentication email to other user types. First I thought to do that by creating personal access token for different providers but in this case I will have to send access token to users via email. I think that's not secure way?

Is there any robust and secure way to that with laravel passport? Thank you.

Activity icon

Replied to Creating Personal Access Token For Custom Provider

Actually main question under that question is 'Are providers useful for personal access clients? There is provider column in personal access clients table but it's not clear in doc that how to assign providers to personal access clients while creating them or after. Basically, I want to assign a provider to personal access client and create access token for needed clients.

Activity icon

Replied to Creating Personal Access Token For Custom Provider

This returns client_id. Besides, returns same id again. I want to determine client_id while creating acesstoken. For example I have customer and supplier models and they have different clients, namely providers. When creating token for related model as follows;

return Customer::find(1)->createToken('CustomerToken')->accessToken;

it doesn't add customer client_id into access token record.

Apr
21
2 weeks ago
Activity icon

Replied to Creating Personal Access Token For Custom Provider

I solved my first question. Actually I can get the token without inserting client-id and client secret into .env. It's not clear that where it's used in doc. My second question is, when I add personal access client more than one, it adds last client id into oauth_access_tokens table. I want to determine client id while creating token.

Activity icon

Replied to Creating Personal Access Token For Custom Provider

Is that following question's answer ?

@frankielee and @corvs thank you that fixed.. :) Another question appeared ) When I add more then one personal access client it adds personel access token into last client in database. How can I determine the access client id while creating token?

Apr
20
2 weeks ago
Activity icon

Replied to Creating Personal Access Token For Custom Provider

Normally in oauth_clients table has provider column in Laravel 8. I fill that column with provider's name. But it's same.

Activity icon

Replied to Creating Personal Access Token For Custom Provider

@frankielee and @corvs thank you that fixed.. :) Another question appeared ) When I add more then one personal access client it adds personel access token into last client in database. How can I determine the access client id while creating token?

Thank you

Activity icon

Started a new Conversation Creating Personal Access Token For Custom Provider

Hi everyone. I need to create accesstoken for a table except users table. I have customers table on my app. Customers are not user who log in with password. I just want to give permisson for a specific route and that route fetches api guarded data.

I added following guards and providers into config/auth.php file:

guards = [
	'api-customers' => [
            'driver' => 'passport',
            'provider' => 'customers',
            'hash' => false,
        ],
]

.
.
.

providers = [
	'customers' => [
            'driver' => 'eloquent',
            'model' => App\Models\Customer::class,
        ],
]

When I return following code in a get route, I get Call to undefined method App\Models\Customer::createToken()error.

return Customer::find(1)->createToken('CustomerToken')->accessToken;

I will send a specific link to customers in order to access their page.. How Can ı do that?

Thank you

Apr
14
3 weeks ago
Activity icon

Replied to Creating Symbolic Link In Homestead

Thank you.. Following command solved it without needed composer on host machine.

mklink /J "D:\your-project-path\public\storage" "D:\your-project-path\storage\app\public"
Activity icon

Replied to Creating Symbolic Link In Homestead

It didn't work.. I chekced out all of those solutions. I get same error.

   ErrorException

  symlink(): Protocol error

  at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:315
    311▕      */
    312▕     public function link($target, $link)
    313▕     {
    314▕         if (! windows_os()) {
  ➜ 315▕             return symlink($target, $link);
    316▕         }
    317▕
    318▕         $mode = $this->isDirectory($target) ? 'J' : 'H';
    319▕

      +15 vendor frames
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
Activity icon

Started a new Conversation Creating Symbolic Link In Homestead

Hi everyone. .Yes that question was asked before but answers were not enough satisfying and I couldn't solve that problem..

When php artisan storage:linkcommand is executed in homestead terminal, it gives symlink: protocol error..

What's the solution for this.?

Activity icon

Replied to Laravel 8 Braodcasting Endpoint Problem

Oh, thank you :)

Activity icon

Started a new Conversation Laravel 8 Braodcasting Endpoint Problem

Hi everyone. I get following 405 error while trying to listen private broadcast channel;

"http://site.test/api/broadcasting/auth 405 (Method Not Allowed)"

I made all broadcasting configurations according to laravel 8 doc. When I check the route list, I can't see broadcasting/auth route in the list. It seems like service provider can not produce broadcasting routes.. What did I miss ?

config/app.php

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,

...
	         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\BroadcastServiceProvider::class,


	    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Arr' => Illuminate\Support\Arr::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Broadcast' => Illuminate\Support\Facades\Broadcast::class,

broadcastin.php

    /*
    |--------------------------------------------------------------------------
    | Default Broadcaster
    |--------------------------------------------------------------------------
    |
    | This option controls the default broadcaster that will be used by the
    | framework when an event needs to be broadcast. You may set this to
    | any of the connections defined in the "connections" array below.
    |
    | Supported: "pusher", "ably", "redis", "log", "null"
    |
    */

    'default' => env('pusher', 'null'),

    /*
    |--------------------------------------------------------------------------
    | Broadcast Connections
    |--------------------------------------------------------------------------
    |
    | Here you may define all of the broadcast connections that will be used
    | to broadcast events to other systems or over websockets. Samples of
    | each available type of connection are provided inside this array.
    |
    */

    'connections' => [

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => true,
            ],
        ],

BroadcastServiceProvider.php

/**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Broadcast::routes(['prefix' => 'api', 'middleware' => 'auth:api']);
        require base_path('routes/channels.php');
    }

Thank you..

Apr
06
1 month ago
Activity icon

Replied to Authentication Via Email With Laravel Sanctum

Thanks for your reply. Yes you are right. I am not enough clear.. Actually I mean passwordless authentication. I have customers on my app and they are not in user table and they don't have passwords. But I need to give them a authentication key. There is a page they can see some data which is fetched from api endpoint.

Apr
04
1 month ago
Activity icon

Started a new Conversation Authentication Via Email With Laravel Sanctum

Hi. I have a case which I couldn't solve for authentication. I want to send a special authentication link via e mail to anyone who is not user of app. Is this possible and Can I do that with laravel sanctum?

Mar
17
1 month ago
Activity icon

Started a new Conversation Push Data Size Limit In Redis Broadcast Driver

As you know pusher notification channel has 10 kB data size limit. I need to send bigger data in order to live data update. Does Redis have any limitation or what can you offer to send big data via web socket?

Jan
16
3 months 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 months 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
3 months 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
3 months 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
3 months 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
4 months 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
4 months 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 months 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
4 months 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
5 months 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.