first commit
This commit is contained in:
10
app/Models/Backup.php
Normal file
10
app/Models/Backup.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Backup extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
12
app/Models/Banner.php
Normal file
12
app/Models/Banner.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Banner extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
public $guarded=[];
|
||||
}
|
||||
15
app/Models/Category.php
Normal file
15
app/Models/Category.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function courses(){
|
||||
return $this->hasMany(Course::class);
|
||||
}
|
||||
}
|
||||
10
app/Models/CategoryNotes.php
Normal file
10
app/Models/CategoryNotes.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CategoryNotes extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
42
app/Models/Course.php
Normal file
42
app/Models/Course.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
public $appends = [
|
||||
'paid_amount'
|
||||
];
|
||||
|
||||
public function category(){
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class, 'student_id');
|
||||
}
|
||||
|
||||
public function allTransactions(){
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
public function creditTransactions(){
|
||||
return $this->hasMany(Transaction::class)->where('type','CREDIT');
|
||||
}
|
||||
public function debitTransactions(){
|
||||
return $this->hasMany(Transaction::class)->where('type','DEBIT');
|
||||
}
|
||||
|
||||
protected function paidAmount(): Attribute
|
||||
{
|
||||
$creditAmount = $this->creditTransactions->sum('amount');
|
||||
$debitAmount = $this->debitTransactions->sum('amount');
|
||||
$total = $creditAmount - $debitAmount;
|
||||
return Attribute::make(
|
||||
get: fn ($value) => $total ,
|
||||
);
|
||||
}
|
||||
}
|
||||
11
app/Models/Game.php
Normal file
11
app/Models/Game.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Game extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/Notification.php
Normal file
11
app/Models/Notification.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/Setting.php
Normal file
11
app/Models/Setting.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
15
app/Models/Transaction.php
Normal file
15
app/Models/Transaction.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function course(){
|
||||
return $this->belongsTo(Course::class);
|
||||
}
|
||||
}
|
||||
55
app/Models/User.php
Normal file
55
app/Models/User.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
// protected $fillable = [
|
||||
// 'name',
|
||||
// 'email',
|
||||
// 'password',
|
||||
// 'notification_id',
|
||||
//
|
||||
// ];
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function courses(){
|
||||
return $this->hasMany(Course::class, 'student_id')->latest()->take(config('custom.HOME_RECORD_LIMIT'));
|
||||
}
|
||||
|
||||
public function transactions(){
|
||||
return $this->hasMany(Transaction::class, 'student_id')->latest()->take(config('custom.HOME_RECORD_LIMIT'));
|
||||
}
|
||||
}
|
||||
14
app/Models/Video.php
Normal file
14
app/Models/Video.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Video extends Model
|
||||
{
|
||||
|
||||
public function videoCategory()
|
||||
{
|
||||
return $this->belongsTo(VideoCategory::class);
|
||||
}
|
||||
}
|
||||
16
app/Models/VideoCategory.php
Normal file
16
app/Models/VideoCategory.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VideoCategory extends Model
|
||||
{
|
||||
|
||||
|
||||
public function videos()
|
||||
{
|
||||
return $this->hasMany(Video::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user