Build
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'user_id', 'company_name', 'headline', 'description', 'service_categories',
|
||||
'hiring_regions', 'vendor_onboarding', 'payment_terms', 'website_url',
|
||||
'contact_email', 'public_contact',
|
||||
])]
|
||||
class BuyerProfile extends Model
|
||||
{
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'work_order_id', 'opened_by_id', 'status', 'summary', 'claim', 'response',
|
||||
'evidence_notes', 'recommended_resolution', 'peer_votes', 'resolved_at',
|
||||
])]
|
||||
class Dispute extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'peer_votes' => 'array',
|
||||
'resolved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function workOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkOrder::class);
|
||||
}
|
||||
|
||||
public function openedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'opened_by_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'provider_profile_id', 'platform', 'external_id', 'profile_url', 'status',
|
||||
'rating', 'review_count', 'completed_jobs', 'metrics', 'review_snapshots',
|
||||
'notes', 'imported_at',
|
||||
])]
|
||||
class ExternalProfileImport extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'metrics' => 'array',
|
||||
'review_snapshots' => 'array',
|
||||
'imported_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function providerProfile(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ProviderProfile::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'buyer_id', 'title', 'status', 'service_category', 'location', 'starts_at',
|
||||
'time_window', 'scope', 'required_skills', 'required_tools', 'deliverables',
|
||||
'payment_terms', 'vendor_onboarding', 'visibility',
|
||||
])]
|
||||
class JobPost extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starts_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function buyer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'buyer_id');
|
||||
}
|
||||
|
||||
public function quotes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Quote::class);
|
||||
}
|
||||
|
||||
public function workOrder(): HasOne
|
||||
{
|
||||
return $this->hasOne(WorkOrder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'user_id', 'job_alerts', 'quote_updates', 'work_order_updates',
|
||||
'review_updates', 'dispute_updates', 'email_enabled', 'push_enabled',
|
||||
])]
|
||||
class NotificationPreference extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'job_alerts' => 'boolean',
|
||||
'quote_updates' => 'boolean',
|
||||
'work_order_updates' => 'boolean',
|
||||
'review_updates' => 'boolean',
|
||||
'dispute_updates' => 'boolean',
|
||||
'email_enabled' => 'boolean',
|
||||
'push_enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'user_id', 'business_name', 'headline', 'bio', 'service_area', 'skills',
|
||||
'tools', 'certifications', 'insurance_status', 'rate_card', 'travel_policy',
|
||||
'availability_notes', 'website_url', 'phone', 'public_contact',
|
||||
])]
|
||||
class ProviderProfile extends Model
|
||||
{
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function externalImports(): HasMany
|
||||
{
|
||||
return $this->hasMany(ExternalProfileImport::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable(['job_post_id', 'provider_id', 'status', 'requested_amount', 'rate_summary', 'message', 'terms'])]
|
||||
class Quote extends Model
|
||||
{
|
||||
public function jobPost(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(JobPost::class);
|
||||
}
|
||||
|
||||
public function provider(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'provider_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable(['work_order_id', 'reviewer_id', 'reviewee_id', 'rating', 'body', 'review_type'])]
|
||||
class Review extends Model
|
||||
{
|
||||
public function workOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkOrder::class);
|
||||
}
|
||||
|
||||
public function reviewer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reviewer_id');
|
||||
}
|
||||
|
||||
public function reviewee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reviewee_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable(['user_id', 'title', 'body', 'visibility'])]
|
||||
class SocialPost extends Model
|
||||
{
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
+34
-1
@@ -8,7 +8,10 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
#[Fillable(['name', 'email', 'password'])]
|
||||
@@ -16,7 +19,7 @@ use Spatie\Permission\Traits\HasRoles;
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, HasRoles, Notifiable;
|
||||
use HasApiTokens, HasFactory, HasRoles, Notifiable;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -30,4 +33,34 @@ class User extends Authenticatable
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function providerProfile(): HasOne
|
||||
{
|
||||
return $this->hasOne(ProviderProfile::class);
|
||||
}
|
||||
|
||||
public function buyerProfile(): HasOne
|
||||
{
|
||||
return $this->hasOne(BuyerProfile::class);
|
||||
}
|
||||
|
||||
public function notificationPreference(): HasOne
|
||||
{
|
||||
return $this->hasOne(NotificationPreference::class);
|
||||
}
|
||||
|
||||
public function socialPosts(): HasMany
|
||||
{
|
||||
return $this->hasMany(SocialPost::class);
|
||||
}
|
||||
|
||||
public function jobPosts(): HasMany
|
||||
{
|
||||
return $this->hasMany(JobPost::class, 'buyer_id');
|
||||
}
|
||||
|
||||
public function quotes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Quote::class, 'provider_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
#[Fillable([
|
||||
'job_post_id', 'buyer_id', 'provider_id', 'accepted_quote_id', 'status',
|
||||
'status_history', 'agreed_terms', 'deliverables_checklist', 'completion_notes',
|
||||
'en_route_at', 'on_site_at', 'started_at', 'completed_at', 'approved_at', 'closed_at',
|
||||
])]
|
||||
class WorkOrder extends Model
|
||||
{
|
||||
public const STATUSES = [
|
||||
'assigned', 'en_route', 'on_site', 'in_progress', 'completed',
|
||||
'buyer_approved', 'disputed', 'closed', 'cancelled',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status_history' => 'array',
|
||||
'en_route_at' => 'datetime',
|
||||
'on_site_at' => 'datetime',
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
'approved_at' => 'datetime',
|
||||
'closed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function jobPost(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(JobPost::class);
|
||||
}
|
||||
|
||||
public function buyer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'buyer_id');
|
||||
}
|
||||
|
||||
public function provider(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'provider_id');
|
||||
}
|
||||
|
||||
public function acceptedQuote(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Quote::class, 'accepted_quote_id');
|
||||
}
|
||||
|
||||
public function reviews(): HasMany
|
||||
{
|
||||
return $this->hasMany(Review::class);
|
||||
}
|
||||
|
||||
public function disputes(): HasMany
|
||||
{
|
||||
return $this->hasMany(Dispute::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user