feat: add Company model and TrackedModel trait; update Park model to use Company as owner

This commit is contained in:
pacnpal
2025-02-26 12:58:46 -05:00
parent f6d0ecd82e
commit bcfab9fb74
3 changed files with 80 additions and 2 deletions

34
app/Models/Company.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Traits\TrackedModel;
class Company extends Model
{
use HasFactory, TrackedModel;
protected $fillable = [
'name',
'slug',
'description',
'website',
'founded_year',
'headquarters',
'status'
];
public function parks()
{
return $this->hasMany(Park::class, 'owner_id');
}
public function updateStatistics()
{
// Implementation matching Django's Company.update_statistics()
$this->loadCount('parks');
$this->save();
}
}