diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 004e8ed..6efea09 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -46,6 +46,9 @@ class HomeController extends Controller
$item = date('Y-m-d', $x);
}
});
- return view('home',compact('dates','visits'));
+
+ $mobiles_count = Visitor::where('created_at', '>=', Carbon::now()->subMonth())->where('is_mobile',1)->count();
+ $all_visitor = Visitor::where('created_at', '>=', Carbon::now()->subMonth())->count();
+ return view('home',compact('dates','visits','all_visitor','mobiles_count'));
}
}
diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php
index 09dbb53..68e14a1 100644
--- a/app/Models/Invoice.php
+++ b/app/Models/Invoice.php
@@ -17,6 +17,11 @@ class Invoice extends Model
return 'hash';
}
+
+ public function orders()
+ {
+ return $this->hasMany(Order::class);
+ }
protected static function boot()
{
parent::boot();
diff --git a/app/Models/User.php b/app/Models/User.php
index c2f4c02..80af713 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -58,19 +58,49 @@ class User extends Authenticatable
{
return $this->hasMany(Post::class);
}
+ public function postsPercent()
+ {
+ if (Post::count() == 0) {
+ return 100;
+ }
+ return $this->posts()->count() * 100 / Post::count();
+ }
public function products()
{
return $this->hasMany(Product::class);
}
+ public function productsPercent()
+ {
+
+ if (Product::count() == 0) {
+ return 100;
+ }
+ return $this->products()->count() * 100 / Product::count();
+ }
public function tickets()
{
return $this->hasMany(Ticket::class);
}
+ public function ticketsPercent()
+ {
+ if (Ticket::count() == 0) {
+ return 100;
+ }
+ return $this->tickets()->count() * 100 / Ticket::count();
+ }
public function comments()
{
return $this->morphMany(Comment::class,'commentator');
}
+ public function commentsPercent()
+ {
+ if (Comment::count() == 0) {
+ return 100;
+ }
+ return $this->comments()->count() * 100 / Comment::count();
+ }
+
public function logs()
{
return $this->hasMany(AdminLog::class, 'user_id', 'id');
diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php
index 83320f1..334c6b4 100644
--- a/database/factories/InvoiceFactory.php
+++ b/database/factories/InvoiceFactory.php
@@ -2,6 +2,8 @@
namespace Database\Factories;
+use App\Models\Customer;
+use App\Models\Invoice;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -16,8 +18,17 @@ class InvoiceFactory extends Factory
*/
public function definition(): array
{
+ $date = $this->faker->dateTimeBetween('-1 months', 'now');
return [
- //
+ 'customer_id' => Customer::inRandomOrder()->first()->id,
+ 'status' => Invoice::$invoiceStatus[rand(0,count(Invoice::$invoiceStatus)-1)],
+ 'desc' => $this->faker->realText(),
+ 'address_id' => null,
+ 'transport_id' => null,
+ 'transport_price' => 0,
+ 'created_at' => $date,
+ 'updated_at' => $date,
+ 'total_price' => 0,
];
}
}
diff --git a/database/migrations/2024_05_07_130806_create_invoices_table.php b/database/migrations/2024_05_07_130806_create_invoices_table.php
index b4dec43..d03c9d7 100644
--- a/database/migrations/2024_05_07_130806_create_invoices_table.php
+++ b/database/migrations/2024_05_07_130806_create_invoices_table.php
@@ -17,6 +17,7 @@ return new class extends Migration
$table->unsignedBigInteger('customer_id');
$table->enum("status",\App\Models\Invoice::$invoiceStatus)->nullable()->default("PENDING");
$table->unsignedBigInteger('total_price')->nullable()->default(0);
+ $table->integer('count')->nullable()->default(0);
$table->json('meta')->nullable();
$table->unsignedBigInteger('discount_id')->nullable()->default(null);
$table->text('desc')->nullable()->default(null);
diff --git a/database/migrations/2024_05_07_130906_create_orders_table.php b/database/migrations/2024_05_07_130906_create_orders_table.php
index ca64160..682e3ba 100644
--- a/database/migrations/2024_05_07_130906_create_orders_table.php
+++ b/database/migrations/2024_05_07_130906_create_orders_table.php
@@ -15,7 +15,7 @@ return new class extends Migration
$table->id();
$table->unsignedBigInteger('invoice_id');
$table->unsignedBigInteger('product_id');
- $table->unsignedBigInteger('quantity_id');
+ $table->unsignedBigInteger('quantity_id')->nullable();
$table->integer('count')->nullable()->default(1);
$table->unsignedInteger('price_total');
$table->json('data')->nullable()->default(null);;
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index a14da41..8f8897f 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -37,6 +37,7 @@ class DatabaseSeeder extends Seeder
GfxSeeder::class,
AreaSeeder::class,
PartSeeder::class,
+ InvoiceSeeder::class,
VisitorSeeder::class
]
);
diff --git a/database/seeders/InvoiceSeeder.php b/database/seeders/InvoiceSeeder.php
index 0ed848f..cd50c67 100644
--- a/database/seeders/InvoiceSeeder.php
+++ b/database/seeders/InvoiceSeeder.php
@@ -2,6 +2,9 @@
namespace Database\Seeders;
+use App\Models\Invoice;
+use App\Models\Order;
+use App\Models\Product;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -13,5 +16,22 @@ class InvoiceSeeder extends Seeder
public function run(): void
{
//
+ Invoice::factory(70)->create();
+ foreach (Invoice::all() as $it){
+ $total = 0;
+ for ($i = 0; $i <= rand(1,4); $i++) {
+ $order = new Order();
+ $order->product_id = Product::inRandomOrder()->first()->id;
+ $order->count = 1;
+ $order->price_total = rand(100,2000).'000';
+ $total = $order->price_total ;
+ $order->invoice_id = $it->id;
+ $order->save();
+ }
+ $it->total_price = $total;
+ $it->count = $it->orders()->count();
+
+ $it->save();
+ }
}
}
diff --git a/resources/js/app.js b/resources/js/app.js
index ef60ffe..2df137f 100644
--- a/resources/js/app.js
+++ b/resources/js/app.js
@@ -30,6 +30,17 @@ import './panel/setting-section-controller.js';
import './panel/sotable-controller.js';
import './panel/prototypes.js';
+// chartjs.defaults.defaultFontFamily = "Vazir";
+// chartjs.defaults.defaultFontSize = 18;
+
+// chartjs.defaults.backgroundColor = '#0097ff';
+chartjs.defaults.borderColor = 'rgba(255,255,255,0.05)';
+chartjs.defaults.color = '#fff';
+chartjs.defaults.font.family = 'Vazir';
+// chartjs.defaults.font.size = '14';
+// chartjs.defaults.font.weight = '100';
+
+
window.chartjs = chartjs;
window.isPaintedChart = false;
diff --git a/resources/sass/panel/_common.scss b/resources/sass/panel/_common.scss
index e9738d6..be6cd57 100644
--- a/resources/sass/panel/_common.scss
+++ b/resources/sass/panel/_common.scss
@@ -272,3 +272,5 @@ a.btn,a.action-btn,a.circle-btn{
flex-wrap: wrap;
}
}
+
+
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 5bb7197..c948511 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -12,7 +12,7 @@