Init(Core): Change repo
This commit is contained in:
67
app/Models/Art.php
Normal file
67
app/Models/Art.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Art extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'text', 'is_free', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id', 'division_id', 'branch_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function chapter()
|
||||
{
|
||||
return $this->belongsTo(Chapter::class);
|
||||
}
|
||||
|
||||
public function part()
|
||||
{
|
||||
return $this->belongsTo(Part::class);
|
||||
}
|
||||
|
||||
public function volum()
|
||||
{
|
||||
return $this->belongsTo(Volum::class);
|
||||
}
|
||||
|
||||
public function law()
|
||||
{
|
||||
return $this->belongsTo(Law::class);
|
||||
}
|
||||
|
||||
public function book()
|
||||
{
|
||||
return $this->belongsTo(Book::class);
|
||||
}
|
||||
|
||||
public function section()
|
||||
{
|
||||
return $this->belongsTo(Section::class);
|
||||
}
|
||||
|
||||
public function gate()
|
||||
{
|
||||
return $this->belongsTo(Gate::class);
|
||||
}
|
||||
|
||||
public function judicialPrecedents()
|
||||
{
|
||||
return $this->belongsToMany(JudicialPrecedent::class, 'art_judicial_precedent');
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")
|
||||
->orWhere('text', 'like', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")
|
||||
->orWhere('text', 'like', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
61
app/Models/Book.php
Normal file
61
app/Models/Book.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'volum_id', 'law_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public function sections()
|
||||
{
|
||||
return $this->hasMany(Section::class);
|
||||
}
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function chapters()
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function divisions()
|
||||
{
|
||||
return $this->hasMany(Division::class);
|
||||
}
|
||||
|
||||
public function branchs()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
}
|
||||
29
app/Models/Branch.php
Normal file
29
app/Models/Branch.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Branch extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'chapter_id', 'part_id', 'volum_id', 'law_id', 'book_id', 'section_id', 'gate_id','division_id'];
|
||||
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
32
app/Models/Category.php
Normal file
32
app/Models/Category.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'type'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function laws()
|
||||
{
|
||||
return $this->hasMany(Law::class);
|
||||
}
|
||||
|
||||
|
||||
public static function getType()
|
||||
{
|
||||
return [
|
||||
'hagigi' => 'حقیقی',
|
||||
'kifari' => 'کیفری'
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Models/Chapter.php
Normal file
51
app/Models/Chapter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Chapter extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function gate()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
71
app/Models/Division.php
Normal file
71
app/Models/Division.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Division extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id'];
|
||||
|
||||
|
||||
public function sections()
|
||||
{
|
||||
return $this->hasMany(Section::class);
|
||||
}
|
||||
|
||||
public function division()
|
||||
{
|
||||
return $this->hasMany(Division::class);
|
||||
}
|
||||
|
||||
public function chapters()
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function gate()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public function branchs()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
|
||||
}
|
||||
21
app/Models/Folder.php
Normal file
21
app/Models/Folder.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Folder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name'
|
||||
];
|
||||
|
||||
public function arts()
|
||||
{
|
||||
return $this->belongsToMany(Art::class, 'folder_art');
|
||||
}
|
||||
}
|
||||
21
app/Models/FolderArt.php
Normal file
21
app/Models/FolderArt.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FolderArt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'folder_id',
|
||||
'art_id'
|
||||
];
|
||||
|
||||
public function arts()
|
||||
{
|
||||
return $this->belongsTo(Art::class,'art_id');
|
||||
}
|
||||
}
|
||||
43
app/Models/Gate.php
Normal file
43
app/Models/Gate.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'part_id', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
26
app/Models/JudicialPrecedent.php
Normal file
26
app/Models/JudicialPrecedent.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JudicialPrecedent extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'ruling_number',
|
||||
'ruling_date',
|
||||
'subject',
|
||||
'full_text',
|
||||
'issuing_authority'
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function arts()
|
||||
{
|
||||
return $this->belongsToMany(Art::class, 'art_judicial_precedent');
|
||||
}
|
||||
}
|
||||
86
app/Models/Law.php
Normal file
86
app/Models/Law.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Law extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'is_locked', 'category_id', 'price','image'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'category_id');
|
||||
}
|
||||
|
||||
public function sections()
|
||||
{
|
||||
return $this->hasMany(Section::class);
|
||||
}
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function chapters()
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function divisions()
|
||||
{
|
||||
return $this->hasMany(Division::class);
|
||||
}
|
||||
|
||||
public function branchs()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function arts()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public function volums()
|
||||
{
|
||||
return $this->hasMany(Volum::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
|
||||
public function getIsLockedAttribute($value)
|
||||
{
|
||||
return (bool) $value;
|
||||
}
|
||||
|
||||
public function setIsLockedAttribute($value)
|
||||
{
|
||||
$this->attributes['is_locked'] = $value ? 1 : 0;
|
||||
}
|
||||
|
||||
public function getImageAttribute($value)
|
||||
{
|
||||
return $value ? secure_asset('images/' . $value) : null;
|
||||
}
|
||||
}
|
||||
21
app/Models/LikeArt.php
Normal file
21
app/Models/LikeArt.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LikeArt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'art_id'
|
||||
];
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->belongsTo(Art::class);
|
||||
}
|
||||
}
|
||||
16
app/Models/LikeSection.php
Normal file
16
app/Models/LikeSection.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LikeSection extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'section_id',
|
||||
'user_id'
|
||||
];
|
||||
}
|
||||
18
app/Models/Note.php
Normal file
18
app/Models/Note.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Note extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'art_id',
|
||||
'note',
|
||||
'color_code'
|
||||
];
|
||||
}
|
||||
35
app/Models/Notification.php
Normal file
35
app/Models/Notification.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'notifications';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'notification_user')
|
||||
->withPivot('read_at')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifications that a user has not read (no pivot row with read_at set).
|
||||
*/
|
||||
public static function scopeUnreadForUser($query, $userId)
|
||||
{
|
||||
return $query->whereDoesntHave('users', function ($q) use ($userId) {
|
||||
$q->where('user_id', $userId)->whereNotNull('notification_user.read_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
32
app/Models/Order.php
Normal file
32
app/Models/Order.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'price',
|
||||
'status',
|
||||
'transaction_id',
|
||||
];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public static function getStatues()
|
||||
{
|
||||
return [
|
||||
'paid' => 'پرداخت شده',
|
||||
'unpaid' => 'پرداخت نشده'
|
||||
];
|
||||
}
|
||||
}
|
||||
42
app/Models/Part.php
Normal file
42
app/Models/Part.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Part extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'chapter_id', 'section_id', 'book_id', 'volum_id', 'law_id','division_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
30
app/Models/PaymentTransaction.php
Normal file
30
app/Models/PaymentTransaction.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentTransaction extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'subscribe_plan_id',
|
||||
'transaction_id',
|
||||
'reference_id',
|
||||
'amount',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function subscribePlan()
|
||||
{
|
||||
return $this->belongsTo(SubscribePlan::class);
|
||||
}
|
||||
}
|
||||
22
app/Models/RecentArt.php
Normal file
22
app/Models/RecentArt.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RecentArt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'law_id'
|
||||
];
|
||||
|
||||
|
||||
public function law()
|
||||
{
|
||||
return $this->belongsTo(Law::class);
|
||||
}
|
||||
}
|
||||
63
app/Models/Section.php
Normal file
63
app/Models/Section.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Section extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'book_id', 'volum_id', 'law_id','division_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function chapters()
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function gate()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function branch()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function branchs()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
|
||||
31
app/Models/SubscribePlan.php
Normal file
31
app/Models/SubscribePlan.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscribePlan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'price',
|
||||
'expired_day',
|
||||
'is_active',
|
||||
'is_free',
|
||||
'type',
|
||||
'transaction'
|
||||
];
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'user_subscribers');
|
||||
}
|
||||
|
||||
public function userSubscribers()
|
||||
{
|
||||
return $this->hasMany(UserSubscriber::class);
|
||||
}
|
||||
}
|
||||
21
app/Models/Suggestion.php
Normal file
21
app/Models/Suggestion.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Suggestion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'text'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
70
app/Models/User.php
Normal file
70
app/Models/User.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Jetstream\HasProfilePhoto;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens;
|
||||
use HasFactory;
|
||||
use HasProfilePhoto;
|
||||
use Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'mobile',
|
||||
'is_admin',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'profile_photo_url',
|
||||
];
|
||||
|
||||
public function subscribePlans()
|
||||
{
|
||||
return $this->hasMany(UserSubscriber::class);
|
||||
}
|
||||
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->is_admin;
|
||||
}
|
||||
|
||||
public function isSubscriber()
|
||||
{
|
||||
return $this->subscribePlans()->where('expired_at', '>', now())->exists();
|
||||
}
|
||||
|
||||
public function subscribePlan()
|
||||
{
|
||||
return $this->subscribePlans()->where('expired_at', '>', now())->first();
|
||||
}
|
||||
|
||||
public function userSubscribers()
|
||||
{
|
||||
return $this->hasMany(UserSubscriber::class);
|
||||
}
|
||||
|
||||
public function notifications()
|
||||
{
|
||||
return $this->belongsToMany(Notification::class, 'notification_user')
|
||||
->withPivot('read_at')
|
||||
->withTimestamps();
|
||||
}
|
||||
}
|
||||
19
app/Models/UserCode.php
Normal file
19
app/Models/UserCode.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserCode extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'code',
|
||||
'expired_at',
|
||||
];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
}
|
||||
39
app/Models/UserSubscriber.php
Normal file
39
app/Models/UserSubscriber.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserSubscriber extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'subscribe_plan_id',
|
||||
'expired_at',
|
||||
'subscription_id',
|
||||
'purchase_token',
|
||||
'is_free'
|
||||
];
|
||||
|
||||
public function subscribe()
|
||||
{
|
||||
return $this->belongsTo(SubscribePlan::class,'subscribe_plan_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function getExpiredDayAttribute()
|
||||
{
|
||||
return $this->expired_at->diffInDays(now());
|
||||
}
|
||||
|
||||
protected $casts = [
|
||||
'expired_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
25
app/Models/Version.php
Normal file
25
app/Models/Version.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Version extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'number',
|
||||
'log',
|
||||
'force_update',
|
||||
'type'
|
||||
];
|
||||
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
68
app/Models/Volum.php
Normal file
68
app/Models/Volum.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Volum extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['title', 'number', 'law_id'];
|
||||
|
||||
protected $hidden = ['created_at', 'updated_at'];
|
||||
|
||||
public function law()
|
||||
{
|
||||
return $this->belongsTo(Law::class);
|
||||
}
|
||||
public function book()
|
||||
{
|
||||
return $this->hasMany(Book::class);
|
||||
}
|
||||
public function sections()
|
||||
{
|
||||
return $this->hasMany(Section::class);
|
||||
}
|
||||
|
||||
public function gates()
|
||||
{
|
||||
return $this->hasMany(Gate::class);
|
||||
}
|
||||
|
||||
public function parts()
|
||||
{
|
||||
return $this->hasMany(Part::class);
|
||||
}
|
||||
|
||||
public function chapters()
|
||||
{
|
||||
return $this->hasMany(Chapter::class);
|
||||
}
|
||||
|
||||
public function divisions()
|
||||
{
|
||||
return $this->hasMany(Division::class);
|
||||
}
|
||||
|
||||
public function branchs()
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
public function art()
|
||||
{
|
||||
return $this->hasMany(Art::class);
|
||||
}
|
||||
|
||||
public static function search($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->get();
|
||||
}
|
||||
|
||||
public static function searchLimit($searchTerm)
|
||||
{
|
||||
return self::where('title', 'LIKE', "%{$searchTerm}%")->limit(3)->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user