first commit
This commit is contained in:
10
app/Models/ActivityLog.php
Normal file
10
app/Models/ActivityLog.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ActivityLog extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $fillable = ['user_id', 'action', 'model_type', 'model_id', 'old_data', 'new_data', 'created_at'];
|
||||
protected $casts = ['old_data' => 'array', 'new_data' => 'array', 'created_at' => 'datetime'];
|
||||
}
|
||||
20
app/Models/Building.php
Normal file
20
app/Models/Building.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Building extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['owner_id', 'building_name', 'address', 'city', 'status'];
|
||||
|
||||
public function owner() { return $this->belongsTo(Owner::class); }
|
||||
public function units() { return $this->hasMany(Unit::class); }
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
29
app/Models/Contract.php
Normal file
29
app/Models/Contract.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['unit_id', 'person_id', 'contract_type', 'contract_number', 'ejari_no', 'start_date', 'end_date', 'duration_months', 'total_amount', 'status', 'notes'];
|
||||
protected $casts = ['start_date' => 'date', 'end_date' => 'date'];
|
||||
|
||||
public function unit() { return $this->belongsTo(Unit::class); }
|
||||
public function subunits() { return $this->belongsToMany(Subunit::class, 'contract_subunits'); }
|
||||
public function payments() { return $this->hasMany(Payment::class); }
|
||||
|
||||
public function person()
|
||||
{
|
||||
return $this->contract_type === 'owner'
|
||||
? $this->belongsTo(Owner::class, 'person_id')
|
||||
: $this->belongsTo(Tenant::class, 'person_id');
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
17
app/Models/Owner.php
Normal file
17
app/Models/Owner.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Owner extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['name', 'email', 'phone', 'emirates_id', 'passport_no', 'nationality', 'address'];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
20
app/Models/Payment.php
Normal file
20
app/Models/Payment.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['contract_id', 'payment_type', 'payment_number', 'bank_name', 'amount', 'due_date', 'status', 'notes'];
|
||||
protected $casts = ['due_date' => 'date'];
|
||||
|
||||
public function contract() { return $this->belongsTo(Contract::class); }
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
20
app/Models/Subunit.php
Normal file
20
app/Models/Subunit.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Subunit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['unit_id', 'subunit_no', 'subunit_type', 'area_sqft', 'status'];
|
||||
|
||||
public function unit() { return $this->belongsTo(Unit::class); }
|
||||
public function contracts() { return $this->belongsToMany(Contract::class, 'contract_subunits'); }
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
17
app/Models/Tenant.php
Normal file
17
app/Models/Tenant.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['name', 'email', 'phone', 'emirates_id', 'passport_no', 'nationality', 'address'];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
22
app/Models/Unit.php
Normal file
22
app/Models/Unit.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Unit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $fillable = ['building_id', 'unit_no', 'floor_no', 'area_sqft', 'assets', 'status'];
|
||||
protected $casts = ['assets' => 'array'];
|
||||
|
||||
public function building() { return $this->belongsTo(Building::class); }
|
||||
public function subunits() { return $this->hasMany(Subunit::class); }
|
||||
public function contracts() { return $this->hasMany(Contract::class); }
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(fn($model) => $model->created_by = auth()->id());
|
||||
static::updating(fn($model) => $model->updated_by = auth()->id());
|
||||
}
|
||||
}
|
||||
48
app/Models/User.php
Normal file
48
app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user