Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whereDate / whereMonth / whereDay / whereYear / whereTime ??? #1536

Closed
Mellowz opened this issue Jun 9, 2018 · 7 comments · Fixed by #2251
Closed

whereDate / whereMonth / whereDay / whereYear / whereTime ??? #1536

Mellowz opened this issue Jun 9, 2018 · 7 comments · Fixed by #2251

Comments

@Mellowz
Copy link

Mellowz commented Jun 9, 2018

is whereDate / whereMonth / whereDay / whereYear / whereTime are not imlement ?

@msyahidin
Copy link

+1

1 similar comment
@mean-cj
Copy link

mean-cj commented Nov 7, 2019

+1

@Smolevich
Copy link
Contributor

You can implement this function in trait for example or prepare implementation this examples

@AngusDV
Copy link

AngusDV commented Dec 23, 2019

oh i am need a lot please prepare these functions

@gialang
Copy link

gialang commented Jan 5, 2020

+1

@a-zog
Copy link

a-zog commented May 18, 2020

I'm not sure about your use case, but I could solve mine using the native Eloquent features.

If you need to get all posts for a specific time period and display a chart from the result.

  $results =\DB::collection($model)
                ->whereBetween(
                    'created_at',
                    array(
                        Carbon::parse($min),
                        Carbon::parse($max)
                    )
                 )
                ->get()
                ->groupBy(function ($item) {
                    return $item['created_at']->toDateTime()->format("Ym");
                });

Hope that would help

@divine divine linked a pull request May 13, 2021 that will close this issue
@divine divine closed this as completed May 13, 2021
@teamseamive
Copy link

teamseamive commented Jun 19, 2021

Any example to get current month records based on whereDate?
We're trying
Story::where('author_id', $userProfile->_id)->whereDate('timestamp', '>=', now()->month)->first();

We're using this for now

$firstOfMonth = now()->firstOfMonth();
$lastOfMonth  = now()->lastOfMonth();

$stories = Story::where('author_id', $userProfile->_id)
->whereBetween('timestamp', [$firstOfMonth, $lastOfMonth])
->get();

if (count($stories) > 0) {
 //have stories for current month
}

@mongodb mongodb locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants