PHP code example of jaktech / anaphora

1. Go to this page and download the library: Download jaktech/anaphora library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jaktech / anaphora example snippets


Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
    $table->timestamps();
});

class User extends Model
{
    use \Jakteck\Anaphora\Traits\Reportable;
}

/*Only Current Year Users*/
$users = User::yearlyReport()->get();

// or

/*2018 Users*/
$year = 2018; // or Carbon date
$users = User::yearlyReport($year)->get();

/*Only Current Year Users*/
$users = User::thisYearReport()->get();

/*Only Last Year Users*/
$users = User::lastYearReport()->get();

/*Only Current Month Users*/
$users = User::monthlyReport()->get();

// or

/*November Current Year Users*/
$month = 11; // or Carbon date
$users = User::monthlyReport($month)->get();

// or

/*November 2018 Year Users*/
$month = 11; // or Carbon date
$year = 2018; // or Carbon date
$users = User::monthlyReport($month, $year)->get();

/*Only Current Month Users*/
$users = User::thisMonthReport()->get();

/*Only Last Month Users*/
$users = User::thisMonthReport()->get();

/*Only Current Week Users (Mon - Sun)*/
$users = User::thisWeekReport()->get();

/*Only Last Week Users (Mon - Sun)*/
$users = User::lastWeekReport()->get();

/*Only Today's Users*/
$users = User::dailyReport()->get();

// or

/*December 27, 2019 Users*/
$date = '2019-12-27'; // or Carbon date
$users = User::dailyReport($date)->get();

/*Only Today's Users*/
$users = User::todayReport()->get();

/*Only Yesterday's Users*/
$users = User::yesterdayReport()->get();

/*Only Last hour to current hour's Users*/
$users = User::hourlyReport()->get();

// or

/*Only 7 am to 2pm Users*/

$from = '07:00'; // or Carbon time
$to = '14:00'; // or Carbon time
$users = User::hourlyReport($from, $to)->get();

// or

/*Only 7 am to 2pm at December 27, 2019 Users*/

$from = '07:00'; // or Carbon time
$to = '14:00'; // or Carbon time
$date = '2019-12-27'; // or Carbon date
$users = User::hourlyReport($from, $to, $date)->get();

$users = User::dailyReport()->where('status', '=', 'inactive')->get();

$data = [];

$date = Carbon::now()->firstOfMonth();
while ($date <= Carbon::now()->endOfMonth()) {
    $users = User::dailyReport($date)
        ->when('condition', function ($query) {
            $query->where('column', 'value');
        })
        ->whereNotIn('column', ['value1', 'value2'])
        ->where('column', 'operator', 'value')
        ->get();

    $data[] = $users;
    $date = $date->copy()->addDay();
}