Skip to content

Commit b63adb8

Browse files
committed
feat(visit): add isit assets
1 parent 0246fb8 commit b63adb8

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

app/Http/Controllers/Admin/AdminController.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Http\Trait\ApiResponseTrait;
7+
use App\Models\Code;
8+
use App\Models\User;
9+
use App\Models\Visit;
710
use Illuminate\Http\Request;
811

912
class AdminController extends Controller
@@ -12,6 +15,20 @@ class AdminController extends Controller
1215

1316
public function index()
1417
{
15-
return $this->success([]);
18+
$codes_count = Code::all()->count();
19+
$users_count = User::all()->count();
20+
$visit_count = Visit::all()->count();
21+
22+
return $this->success([
23+
"codes" => [
24+
"count" => $codes_count
25+
],
26+
"users" => [
27+
"count" => $users_count
28+
],
29+
"visit" => [
30+
"count" => $visit_count
31+
]
32+
]);
1633
}
1734
}

app/Models/Visit.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\SoftDeletes;
7+
8+
class Visit extends Model
9+
{
10+
use SoftDeletes;
11+
12+
protected $fillable = [
13+
"ip",
14+
"user_agent"
15+
];
16+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('visits', function (Blueprint $table) {
15+
$table->id();
16+
$table->string("ip");
17+
$table->string("user_agent");
18+
$table->softDeletes();
19+
$table->timestamps();
20+
});
21+
}
22+
23+
/**
24+
* Reverse the migrations.
25+
*/
26+
public function down(): void
27+
{
28+
Schema::dropIfExists('visits');
29+
}
30+
};

0 commit comments

Comments
 (0)