$schedule->command('my:command')->cron('*/7 07-22 * * *');
select
departments.id,
departments.department,
count(*) as count
from departments
join employees on employees.department_id = departments.id
group by departments.id, departments.name;
select
departments.id,
departments.department,
count(*) as count
from departments
left join employees on employees.department_id = departments.id
group by departments.id, departments.name;
class JobHandleSomeClass implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected MyClass $myClass;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(MyClass $myClass)
{
$this->myClass =$myClass;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->myClass->runMethod1();
$this->myClass->runMethod2();
$this->myClass->runMethod3();
........
}
}
Я поэтому и задал этот вопрос, чтобы люди поделились опытом, подсказали как это лучше сделать
select users.name, bank_props.bik, bank_props.inn, bank_props.kpp, bank_props.individual_guid, settlements.period
from users
join
(select max(period) as date, user_id from bank_props where active = true group by user_id) as t_bank
on (users.id = t_bank.user_id)
join bank_props on t_bank.user_id = bank_props.user_id and bank_props.period = t_bank.date
join
(select max(period) as date, user_id from settlements where status = 'COMPLETED' group by user_id) as t_settlements
on (users.id = t_settlements.user_id)
join settlements on t_settlements.user_id = settlements.user_id and settlements.period = t_settlements.date;
public function getPropAttribute(): string
{
return 'prop';
}
public function newInstance($attributes = [], $exists = false)
{
$model = parent::newInstance($attributes, $exists);
$model->setAppends($this->appends);
return $model;
}
(new \App\Models\User())->setAppends(['prop'])->newModelQuery()->get()->first()->toArray()
^ array:8 [
"id" => 2
"name" => "Алексеев Глеб Дмитриевич"
"email" => "fmarkov@example.com"
"email_verified_at" => "2022-06-16T02:18:03.000000Z"
"deleted_at" => null
"created_at" => "2022-06-16T02:18:03.000000Z"
"updated_at" => "2022-06-16T02:18:03.000000Z"
"prop" => "prop"
]
Route::delete('/project/{project}', [Controller::class, 'method'])->can('delete', 'project');
public function delete()
{
$result = parent::delete();
if($result){
$this->deleteImageProject($this->logo);
}
return $result;
}
public function destroy(Project $project)
{
$project->delete();
return response('', 204);
}
If a DELETE method is successfully applied, the origin server SHOULD
send a 202 (Accepted) status code if the action will likely succeed
but has not yet been enacted, a 204 (No Content) status code if the
action has been enacted and no further information is to be supplied,
or a 200 (OK) status code if the action has been enacted and the
response message includes a representation describing the status.
select * from (select
least(city.id, city2.id) as id1,
greatest(city.id, city2.id) as id2
from city
join city as city2 on city.id != city2.id
group by least(city.id, city2.id), greatest(city.id, city2.id)
) as t join city as city1 on city1.id = id1 join city as city2 on city2.id = id2;
select
LEAST(city.name, city1.name), GREATEST(city.name, city1.name)
from city
inner join city as city1 on city1.id != city.id
GROUP BY LEAST(city.name, city1.name), GREATEST(city.name, city1.name);