Laravel 5 如何在laravel中使用多个表?
我需要在laravel中使用这个查询。我不知道如何在模型和控制器中使用这些表 请查收 领先一步。您需要在Laravel中将表定义为复数snake_case,并在sigular camelCase中创建模型 例如,您需要创建模型:Laravel 5 如何在laravel中使用多个表?,laravel-5,Laravel 5,我需要在laravel中使用这个查询。我不知道如何在模型和控制器中使用这些表 请查收 领先一步。您需要在Laravel中将表定义为复数snake_case,并在sigular camelCase中创建模型 例如,您需要创建模型: php artisan make:model monthlyActivity 对于每月的活动表等 然后,您可以使用各种方式执行查询,可以是原始查询,也可以是Laravel生成的查询。 花点时间和精力,然后如果你被绊倒了,发布一个更准确的问题来寻求帮助。 谢谢,@Nish
php artisan make:model monthlyActivity
对于每月的活动表等
然后,您可以使用各种方式执行查询,可以是原始查询,也可以是Laravel生成的查询。
花点时间和精力,然后如果你被绊倒了,发布一个更准确的问题来寻求帮助。
谢谢,@Nisha Garg,请将答案标记为已接受,以便将问题标记为已在堆栈上方关闭。谢谢,请将答案标记为已接受,这样问题就可以标记为已结束。谢谢,但我在这个查询中遇到了一个问题,我是否应该再添加一个问题?
select mon,year,
combo,
registered,
forwardedbycmo,
clarification,
noaction,
disposed,mon_srno,undertaken
from monthly_activities
union
select extract('month' from actiondate) as mon,extract('year' from actiondate) as year,
extract('year' from actiondate)|| '-' ||to_char(to_timestamp (extract('month' from actiondate)::text, 'MM'), 'TMMon') as combo,
sum(case when actioncode = '00' then 1 else 0 end) as registered,
sum(case when actioncode = '4T' and fromorg='CMOFF' then 1 else 0 end) as forwardedbycmo,
sum(case when actioncode = '4D' and fromorg='CMOFF' then 1 else 0 end) as clarification,
sum(case when actioncode = '10' then 1 else 0 end) as noaction,
sum(case when actioncode = '50' then 1 else 0 end) as disposed,null as mon_srno,
sum(case when actioncode = '40' and fromorg='CMOFF' then 1 else 0 end) as undertaken
from actionhistory where extract(month from actiondate)=extract(month from current_date)
and extract(year from actiondate)=extract(year from current_date)
group by mon,year order by year,mon;
";