1
0
Fork 0

app/Models/CharacterProfession.php: Add specialization relationship

This commit is contained in:
Henrik Hautakoski 2021-07-11 15:31:34 +02:00
parent 5314028388
commit ad66ef86ab
2 changed files with 8 additions and 0 deletions

View file

@ -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.
*/

View file

@ -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),
];
}