Type Ratings | New Feature (#1360)
* Type Ratings Adding "Type Rating" definition and assignment possibility to v7 core. * Update ProfileController.php * StyleFix 1 * Update settings.yml Change description text as requested
This commit is contained in:
@@ -107,4 +107,9 @@ class Subfleet extends Model
|
||||
return $this->belongsToMany(Rank::class, 'subfleet_rank')
|
||||
->withPivot('acars_pay', 'manual_pay');
|
||||
}
|
||||
|
||||
public function typeratings()
|
||||
{
|
||||
return $this->belongsToMany(Typerating::class, 'typerating_subfleet', 'subfleet_id', 'typerating_id');
|
||||
}
|
||||
}
|
||||
|
||||
36
app/Models/Typerating.php
Normal file
36
app/Models/Typerating.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Contracts\Model;
|
||||
|
||||
class Typerating extends Model
|
||||
{
|
||||
public $table = 'typeratings';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'type',
|
||||
'description',
|
||||
'image_url',
|
||||
];
|
||||
|
||||
// Validation
|
||||
public static $rules = [
|
||||
'name' => 'required',
|
||||
'type' => 'required',
|
||||
'description' => 'nullable',
|
||||
'image_url' => 'nullable',
|
||||
];
|
||||
|
||||
// Relationships
|
||||
public function subfleets()
|
||||
{
|
||||
return $this->belongsToMany(Subfleet::class, 'typerating_subfleet', 'typerating_id', 'subfleet_id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'typerating_user', 'typerating_id', 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use App\Models\Traits\JournalTrait;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* @property int id
|
||||
@@ -42,6 +43,7 @@ use Laratrust\Traits\LaratrustUserTrait;
|
||||
* @property UserFieldValue[] fields
|
||||
* @property Role[] roles
|
||||
* @property Subfleet[] subfleets
|
||||
* @property TypeRating[] typeratings
|
||||
*
|
||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||
* @mixin \Illuminate\Notifications\Notifiable
|
||||
@@ -52,6 +54,7 @@ class User extends Authenticatable
|
||||
use JournalTrait;
|
||||
use LaratrustUserTrait;
|
||||
use Notifiable;
|
||||
use HasRelationships;
|
||||
|
||||
public $table = 'users';
|
||||
|
||||
@@ -191,8 +194,7 @@ class User extends Authenticatable
|
||||
{
|
||||
$default = config('gravatar.default');
|
||||
|
||||
$uri = config('gravatar.url')
|
||||
.md5(strtolower(trim($this->email))).'?d='.urlencode($default);
|
||||
$uri = config('gravatar.url').md5(strtolower(trim($this->email))).'?d='.urlencode($default);
|
||||
|
||||
if ($size !== null) {
|
||||
$uri .= '&s='.$size;
|
||||
@@ -265,4 +267,14 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->belongsTo(Rank::class, 'rank_id');
|
||||
}
|
||||
|
||||
public function typeratings()
|
||||
{
|
||||
return $this->belongsToMany(Typerating::class, 'typerating_user', 'user_id', 'typerating_id');
|
||||
}
|
||||
|
||||
public function rated_subfleets()
|
||||
{
|
||||
return $this->hasManyDeep(Subfleet::class, ['typerating_user', Typerating::class, 'typerating_subfleet']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user