app/Models/CharacterProfession.php: Add specialization relationship
This commit is contained in:
parent
5314028388
commit
ad66ef86ab
2 changed files with 8 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class CharacterProfession extends Model
|
|||
protected $fillable = [
|
||||
'character_id',
|
||||
'profession_id',
|
||||
'specialization_id',
|
||||
'skill',
|
||||
];
|
||||
|
||||
|
|
@ -48,6 +49,11 @@ class CharacterProfession extends Model
|
|||
return $this->belongsTo(Profession::class);
|
||||
}
|
||||
|
||||
public function specialization()
|
||||
{
|
||||
return $this->belongsTo(Spell::class, 'specialization_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the character that has this profession.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
|||
|
||||
use App\Models\Character;
|
||||
use App\Models\Profession;
|
||||
use App\Models\Spell;
|
||||
|
||||
class CharacterProfessionFactory extends Factory
|
||||
{
|
||||
|
|
@ -43,6 +44,7 @@ class CharacterProfessionFactory extends Factory
|
|||
$id = self::$ids[$ch_id][] = Profession::whereNotIn('id', self::$ids[$ch_id])->get()->random()->id;
|
||||
return $id;
|
||||
},
|
||||
'specialization_id' => Spell::factory(),
|
||||
'skill' => $this->faker->numberBetween(1, 375),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue