0

I have a manual job that I want to check/test. The job is located here:

app/Jobs/Leads/LinkFaceBookUTM.php

The contents of the job is:

<?php

namespace App\Jobs\Leads;

use Illuminate\Bus\Queueable;
use App\Models\Customers\Leads;
use App\Models\Customers\LeadDetails;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class LinkFaceBookUTM implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $lead;
    /**
     * Create a new job instance.
     * @param Leads $lead;
     *
     * @return void
     */
    public function __construct(Leads $lead)
    {
        $this->lead = $lead;
    }

     * @return void
     */
    public function handle()
    {
      
        $payload = [];
        $leads = LeadDetails::whereField('utm-session');
        return $leads;
    }
}

To test the job out I am running the below:

php artisan Leads/LinkFaceBookUTM:run

I am getting the below error though:

There are no commands defined in the "Leads/LinkFaceBookUTM" namespace.
SJW525
  • 51
  • 1
  • 9
  • You can run through tinker ```php artisan tinker``` for more follow https://laravel.com/docs/8.x/queues#connections-vs-queues – abSiddique Mar 26 '21 at 19:17
  • @absiddiqueLive But I need to be able to run that jog from command line. I don't see what it says there are no commands defined in the namepspace – SJW525 Mar 26 '21 at 19:31
  • If you wish to test via command line just run the below code in ```tinker``` ```use App\Jobs\Leads\LinkFaceBookUTM;``` ```use App\Models\Customers\Leads;``` ```LinkFaceBookUTM::dispatch(new Leads());``` and check your job table. If you need to use it in command line in your server as backend service, you have to write a command/scheduler in Laravel – abSiddique Mar 26 '21 at 19:39
  • @absiddiqueLive Is there a reason why I can't run it as a job as I'm trying to do? – SJW525 Mar 26 '21 at 19:43
  • Laravel won't offer the option to run a job through php artisan, but you can write a command to run a job through php artisan It may help https://stackoverflow.com/questions/43357472/how-to-manually-run-a-laravel-lumen-job-using-command-line – abSiddique Mar 26 '21 at 19:47
  • @absiddiqueLive Ok, I think what I really wanted was to create a laravel command then, and not a job. Thank you! – SJW525 Mar 26 '21 at 20:20

0 Answers0