To place job on the queue using tinker: use Illuminate\Contracts\Bus\Dispatcher; //for command app(Dispatcher::class)->dispatch($command); //for job app(Dispatcher::class)->dispatch(new App\Jobs\TestJob); //or $pending =
Tag: Laravel
Ways to Dispatch Laravel Work Process
With minimum configuration according to this stackoverflow post: nohup php artisan queue:work –daemon & This will run the queue:work process
Larave Nested Where Clause
A good link to look at: https://stackoverflow.com/questions/60559442/nested-orwhere-in-one-where-laravel To implement the following SQL: select * from logs where created_at between “2021-02-23”
Laravel Config and Env
Good discussion env() calls work as long as you don’t use php artisan config:cache. So it’s very dangerous because it
Laravel Multiple Database Connection
For Laravel > 5.3 Add in .env file properties of the second connection (DB_HOST, DB_PORT, DB_DATABASE, DBUSERNAME, DB_PASSWORD) Add second
Laravel Console Command
Generate the command php artisan make:command command_name Call command php artisan command:command_name –options arguments Optionally, register An Command, add yourCommand
Laravel Job and Queue
This post shows the steps on how to run queue in database using background worker process. Useful tutorials: https://scotch.io/tutorials/why-laravel-queues-are-awesome https://laravel-news.com/laravel-jobs-and-queues-101
Laravel Query Builder WhereRaw Example
A query builder whereraw tutorial whereRaw($sql, array $bindings = [], $boolean = ‘and’) A couple of examples: $g = TableName::whereRaw(‘LOWER(worker_location)
Laravel Query Performance
Here’s a way to assess the performance of a query: Start tinker in the Laravel project directory php artisan tinker
Laravel Eloquent Collection Tips
Adding a column with constant value to existing collection: $existing_col->map(function ($col) { $col[‘url’] = ‘http://your.url/here’; return $col; }); To add