Laravel Analytics Package

https://opengraph.githubassets.com/7a32e2a07c8bc450619e5de7ef0d00f65b4dada54b28026615b518879acf43fb/coderflexx/laravisit

Laravisit Logo

The Latest Version on Packagist
GitHub Tests Action Status
GitHub Code Style Action Status

A clean way to track your pages & understand your user’s behavior

Installation

You can install the package via composer:

composer require coderflexx/laravisit

You can publish the config file with:

php artisan vendor:publish --provider="Coderflex\\Laravisit\\LaravisitServiceProvider"

then, run database migration

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | User Namespace
    |--------------------------------------------------------------------------
    |
    | This value informs Laravist which namespace you will be 
    | selecting to get the user model instance
    | If this value equals to null, "\Coderflex\Laravisit\Models\User" will be used 
    | by default.
    |
    */
    'user_namespace' => "\Coderflex\Laravisit\Models\User",
];

Usage

Use HasVisits Trait

The first thing you need to do is, to use HasVisits trait, and implement CanVisit interface.

namespace App\Models\Post;

use Coderflex\Laravisit\Concerns\CanVisit;
use Coderflex\Laravisit\Concerns\HasVisits;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Post extends Model implements CanVisit
{
    ...
    use HasFactory;
    use HasVisits;
    ...
}

After this step, you are reading to go, and when you need to track a page, do it like this:

You can chain methods to the visit method. Here is a list of the available methods:

METHOD SYNTAX DESCRIPTION EXAMPLE
withIp() string $ip = null Set an Ip address (default request()->ip()) $post->visit()->withIp()
withData() array $data Set custom data $post->visit()->withData(['region' => 'USA'])
withUser() Model $user = null Set a user model (default auth()->user()) $user->visit()->withUser()

By default, you will have unique visits each day using dailyInterval() method. Meaning, when the users access the page multiple times in the day time frame, you will see just one record related to them.

If you want to log users access to page with different timeframes, here are a bunch of useful methods:

METHOD SYNTAX DESCRIPTION EXAMPLE
hourlyInterval() void Log visits each hour $post->visit()->hourlyIntervals()->withIp();
dailylyInterval() void Log visits each daily $post->visit()->dailylyIntervals()->withIp();
weeklyInterval() void Log visits each week $post->visit()->weeklyIntervals()->withIp();
monthlyInterval() void Log visits each month $post->visit()->monthlyIntervals()->withIp();
yearlyInterval() void Log visits each year $post->visit()->yearlyIntervals()->withIp();
customInterval() mixed $interval Log visits within a custom interval $post->visit()->customInterval( now()->subYear() )->withIp();

Get The Records With Popular Time Frames

After the visits get logged, you can retrieve the data by the following method:

METHOD SYNTAX DESCRIPTION EXAMPLE
withTotalVisitCount() void get total visit count Post::withTotalVisitCount()->first()->visit_count_total
popularAllTime() void get popular visits all time Post::popularAllTime()->get()
popularToday() void get popular visits in the current day Post::popularToday()->get()
popularLastDays() int $days get popular visits last given days Post::popularLastDays(10)->get()
popularThisWeek() void get popular visits this week Post::popularThisWeek()->get()
popularLastWeek() void get popular visits last week Post::popularLastWeek()->get()
popularThisMonth() void get popular visits this month Post::popularThisMonth()->get()
popularLastMonth() void get popular visits last month Post::popularLastMonth()->get()
popularThisYear() void get popular visits this year Post::popularThisYear()->get()
popularLastYear() void get popular visits last year Post::popularLastYear()->get()
popularBetween() Carbon $from, Carbon $to get popular visits between custom two dates Post::popularBetween(Carbon::createFromDate(2019, 1, 9), Carbon::createFromDat(2022, 1, 3))->get();

Visit Presenter

This package is coming with helpful decorate model properties, and it uses Laravel Presenter package under the hood.

METHOD SYNTAX DESCRIPTION EXAMPLE
ip() void Get the associated IP from the model instance $post->visits->first()->present()->ip
user() void Get the associated User from the model instance $post->visits->first()->present()->user->name

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Inspiration

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel News Links

Comic for February 18, 2022

https://assets.amuniversal.com/52e417206a70013a9689005056a9545d

Thank you for voting.

Hmm. Something went wrong. We will take a look as soon as we can.

Dilbert Daily Strip

Mom Pulls Gun on Man Attempting to Get Into Her Vehicle in Traffic: ‘It’s Locked and Loaded’

https://www.louderwithcrowder.com/media-library/image.png?id=29367838&width=980

It’s a good thing the media and former Vice President Joe Biden haven’t gotten their way when it comes to snatching everyone’s guns away. If this mother hadn’t had a pistol to ward off this criminal, there’s no telling what might have transpired.

Charise Taylor of New Orleans, mother and United States Air Force veteran, was driving to pick her husband up on Friday when she became stuck in gridlocked traffic. A man rushed up to the door and began to aggressively attempt to pull open her passenger side door. With her 2-year-old son in the car with her, she had to act fast. So she pulled out her handgun and pointed it at the man.


‘It’s locked and loaded’: Mother, Iraq veteran pulls gun on man trying to get into car

www.youtube.com

She says she told him, “It’s locked and loaded,” threatening the man as he tried to gain access to the vehicle. She didn’t have to fire. Like most crooks, they aren’t exactly the bravest of people, and when confronted with their own mortality, they often take off with their tails between their legs.

Taylor says, “You shouldn’t have to navigate your own city like a war zone. It’s un-American. The crime is out of control and it’s terrifying. At this point, having to use the same tactics in an American city that you use in Iraq and Afghanistan simply to navigate through the city it’s scary and I’m not the only mom feeling this way.”

As a fellow Iraq War veteran, I wish I could use an M240B mounted on my truck. I bet it would prevent a lot of this kind of stuff from happening, especially seeing as how police in some liberal cities have all but given up trying to control the rampant crime.

Taylor’s experience like so many other good-guy/gal-with-a-gun stories continues to prove just how vital one’s right to defend oneself is.

The Louder with Crowder Dot Com Website is on Instagram now! Follow us at @lwcnewswire and tell a friend!

Louder With Crowder

Dad Builds $3,000 Chicken Coop To Get 16 Cent Eggs For Free

https://media.babylonbee.com/articles/article-10526-1.jpg

BIRMINGHAM, AL—According to sources, local dad Dave Manheart recently completed a project that will help enable his family to save money on groceries. After much research and 10 weekends of hard labor, Dave has succeeded in constructing a backyard chicken coop. With a small investment of just $3000 on lumber and supplies, he now can get 16¢ eggs for free.  

“With the supply chain issues and inflation, it’s important to be independent,” said Manheart. “Plus, this new chicken coop will look really great on my wife’s Instagram feed, which is what this whole thing is really about.”

Local witnesses described Manheart’s pride in the newly constructed chicken coop as “really cute.” His wife assured reporters that they will enjoy eating ten eggs a day since they are free.  

After leveling a spot in the backyard with a backhoe Dave rented for just $500, putting together the coop was fairly easy and only resulted in two trips to the emergency room with accidental injuries. “Dave says his back will be fine now that he’s no longer lifting lumber, and the doctors had no problem re-attaching his finger,” said his appreciative wife Deb.    

“Daddy bought the cutest little baby chicks!” said his little girl.  “But then our dog Buster ate them so we had to get new chicks.” The dog now has an $800 invisible fence to keep him away from the chicken coop.  

“That was totally worth it,” said Dave as he proudly surveyed his handiwork.

At the time of publication, the homeowners association had issued a fine of $500 for the unapproved chicken coop.

A Babylon Bee subscriber contributed to this report. If you want to get involved with the staff writers at The Babylon Bee, check out our membership options here!


Watch as this Joe Rogan fan fruitlessly tries to get Alexa to play the Joe Rogan Experience.

Subscribe to The Babylon Bee on YouTube

The Babylon Bee

Camp Perry Rifle Matches Scheduled for 2022 Season

Registration is now open for the Civilian Marksmanship Program’s (CMP) series of Garand, Springfield, Vintage and Modern Military (GSMM) rifle matches – set at Ohio’s historic Camp Perry National Guard Training Facility in 2022. Most people would know these events as the Camp Perry Rifle Matches.

RELATED STORY

Brian Zins wins NRA National Pistol Championships at Camp Perry for 10th time.

Electronic Scoring Means More Efficient Matches

Camp Perry’s Petrarca Range will host these matches. The Petrarca Range has an advanced electronic scoring system called KTS. Utilizing these KTS (Kongsberg Target System) targets means faster competition time, with no need for pit duty, and added ease for competitors who can rely on instant, accurate shot monitors located at each firing point.

Dates for the 2022 Camp Perry Rifle Matches at Petrarca Range currently include:

  • Sunday, April 3
  • Saturday, June 25
  • Saturday, Sept. 17

Competitors of all skill levels are welcome to attend these recreational events. These events create a comforting environment for marksmen new to fundamental match procedures. Additionally, these matches also challenge seasoned athletes through friendly competition. Knowledgeable CMP staff members will be on hand at all events to ensure safety and to answer questions.

In addition to the Petrarca matches, a set of highpower rifle 800 Aggregate and Excellence-In-Competition (EIC) events are on the schedule. The host range for these events is Camp Perry’s outdoor Viale Range, on June 25-26, 2022. The matches are ideal for those in the hunt for a Distinguished Rifleman Badge. The Viale matches utilize CMP’s highpower electronic target line and offers the same conveniences as the Petrarca targets. Registration for the matches is available on the CMP website at https://thecmp.org/competitions/matches/camp-perry-matches/.

Space is limited for these events, so sign up today! Additionally, you can find more information, including registration links and an in-depth look into the inner workings of Petrarca’s electronic target system, at https://thecmp.org/ranges/cmp-targets-at-petrarca-range/.

Petrarca is also open weekly!

Petrarca Range will open for public use starting March 14, 2022. Every Monday, guests may use Petrarca during the hours of 9 a.m. to 5 p.m., March through May and September through November. During the summer months (June through August), Petrarca is open from 9 a.m. until 6 p.m. 

Please note: During the National Matches (July 11-Aug. 13), Petrarca Range will be open throughout the week after firing is complete on Rodriguez Range or may be closed due to matches/clinics being held on Petrarca Range. See the detail schedule at https://thecmp.org/ranges/cmp-targets-at-petrarca-range/.

(Editor’s note: this article, with minor changes, was contributed by the CMP Staff Writer Ashley Brugnone)

The post Camp Perry Rifle Matches Scheduled for 2022 Season appeared first on Tactical Life Gun Magazine: Gun News and Gun Reviews.

Tactical Life Gun Magazine: Gun News and Gun Reviews