Besoin d'aide ?

SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value

Avatar de AlexandreCarignan
AlexandreCarignan

Bonjour, j'obtiens l'erreur suivante lors de la création d'un personnage : SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value.

je crois que c'est parce que le user_id n'est pas transférer lors de la sauvegarde dans la base de donné, mais je ne sais pas trop comment l'écrire. Pourriez-vous m'aider?

Un gros merci. Alex.

j'ai été en mesure de passer l'id du user (5) dans l'adresse:

/character/character/create?5

Voici ma ligne de ma page create pour le formulaire:

@section('title')
Création personnage
@endsection

@section('content')

    <div class="row justify-content-center p-4">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Création d’un personnage</div>

                <div class="card-body">
                    <form class="form-floating" action="{{ route('character.character.store') }}" method="POST">

                        @csrf
                        <input type="hidden" id="user_id" value="{{ Auth::user()->id }}" name="user_id">

                        <div class="container border rounded p-4">

                            <div class="row g-3">

                                <div class="col-md">
                                    <div class="form-floating">
                                        <label for="character_name">{{ __('Nom') }}</label>
                                        <input type="text" class="form-control" id="character_name" placeholder="" value="" name="character_name">
                                    </div>
                                </div>

                                <div class="col-md">
                                    <div class="form-floating">
                                        <label for="character_title">{{ __('Titre') }}</label>
                                        <input type="text" class="form-control" id="character_title" placeholder="" value="" name="character_title">
                                    </div>
                                </div>

                                <div class="col-md">
                                    <div class="form-floating">
                                        <label for="character_age">{{ __('Âge') }}</label>
                                        <input type="text" class="form-control" id="character_age" placeholder="" value="" name="character_age">
                                    </div>
                                </div>

                            </div>


                            <div class="container border rounded p-4">
                                <div class="form-floating">
                                    <label for="character_background">{{ __('Histoire du personnage') }}</label>
                                    <textarea class="form-control" placeholder="Écrivez l'histoire ici" id="summernote" style="height: 100px" name="character_background"></textarea>
                                </div>
                            </div>

...
                           
                        <div class="container pt-4">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-btn fa-sign-in"></i>Sauvegarder</button>
                        </div>

                    </form>



                </div>

            </div>

        </div>
    </div>

@endsection

Voici mon controleur.

<?php

namespace App\Http\Controllers\Character;

use App\Http\Controllers\Controller;
use App\User;
use App\Models\Character;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\support\Facades\Gate;

class CharacterController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $user = User::id();
        // tu sélectionnes toutes les entrées de la table 'cities'
        return view('character.index')->with('user', $user_id);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {

        return view('character.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

        //$user = Auth::user(); // Retrieve the currently authenticated user...
        // Retrieve the currently authenticated user's ID..
        //$user_id = Auth::user()->id;
        //$user_id = User::findOrFail($id);
        Character::create($request->all());


        return view('character.index')->with('user', $user_id);
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Character  $character
     * @return \Illuminate\Http\Response
     */
    public function show(Character $character)
    {
        return view('character.show', [
            'character' => Character::findOrFail($id)
        ]);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Character  $character
     * @return \Illuminate\Http\Response
     */
    public function edit(Character $character)
    {
        return view('character.edit', [

            'character' => Character::findOrFail($id)
        ]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Character  $character
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Character $character)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Character  $character
     * @return \Illuminate\Http\Response
     */
    public function destroy(Character $character)
    {
        $character = $request->all();
        $character = Character::find($id);
        $character->delete();

        return redirect()->route('editor.user.index');
    }
}

voici mon modèle user.php

<?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function roles()
    {
        return $this->belongsToMany('App\Role');
    }

    public function isAdmin()
    {
        return $this->roles()->where('name', 'admin')->first();
    }

    public function hasAnyRole(array $roles)
    {
        return $this->roles()->whereIn('name', $roles)->first();
    }
}

voici mon modèle character.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Character extends Model
{
    protected $fillable = [
        'character_name',
        'character_age',
        'character_title',
        'character_date_of_birth',
        'character_month_of_birth',
        'character_year_of_birth',
        'character_experience',
        'character_essence_game',
        'character_essence_total',
        'character_house_name',
        'character_house_rank',
        'character_house_dogma',
        'character_guild_name',
        'character_guild_dogma',
        'character_career_name',
        'character_career_physic',
        'character_career_physic_bonus',
        'character_career_physic_penalty',
        'character_career_mental',
        'character_career_mental_bonus',
        'character_career_mental_penalty',
        'character_career_reaction',
        'character_career_reaction_bonus',
        'character_career_reaction_penalty',
        'character_life_point_max',
        'character_life_point_game',
        'character_life_point_bonus',
        'character_life_point_percentage_bonus',
        'character_magic_point_max',
        'character_magic_point_game',
        'character_magic_point_bonus',
        'character_magic_point_percentage_bonus',
        'character_magic_force_arcana_max',
        'character_magic_force_arcana_game',
        'character_magic_force_arcana_bonus',
        'character_magic_force_arcana_percentage_bonus',
        'character_magic_force_holy_max',
        'character_magic_force_holy_game',
        'character_magic_force_holy_bonu',
        'character_magic_force_holy_percentage_bonus',
        'character_magic_force_cursed_max',
        'character_magic_force_cursed_game',
        'character_magic_force_cursed_bonus',
        'character_magic_force_cursed_percentage_bonus',
        'character_gold',
        'character_bank',
        'character_lap_speed',
        'character_movement',
        'character_movement_bonus_humanTerritory',
        'character_movement_bonus_inside',
        'character_movement_bonus_savageTerritory',
        'character_movement_bonus_naval',
        'character_movement_bonus_mount',
        'character_fields',
        'character_fields_bonus_spell',
        'character_weapon1_name',
        'character_weapon1_type',
        'character_weapon1_scope',
        'character_weapon1_attack',
        'character_weapon1_attack_b',
        'character_weapon1_fumble',
        'character_weapon1_damage',
        'character_weapon1_dices',
        'character_weapon1_critic',
        'character_weapon1_face',
        'character_weapon1_flank',
        'character_weapon1_back',
        'character_weapon1_value',
        'character_weapon2_name',
        'character_weapon2_type',
        'character_weapon2_scope',
        'character_weapon2_attack',
        'character_weapon2_attack_b',
        'character_weapon2_fumble',
        'character_weapon2_damage',
        'character_weapon2_dices',
        'character_weapon2_critic',
        'character_weapon2_face',
        'character_weapon2_flank',
        'character_weapon2_back',
        'character_weapon2_value',
        'character_weapon3_name',
        'character_weapon3_type',
        'character_weapon3_scope',
        'character_weapon3_attack',
        'character_weapon3_attack_b',
        'character_weapon3_fumble',
        'character_weapon3_damage',
        'character_weapon3_dices',
        'character_weapon3_critic',
        'character_weapon3_face',
        'character_weapon3_flank',
        'character_weapon3_back',
        'character_weapon3_value',
        'character_weapon4_name',
        'character_weapon4_type',
        'character_weapon4_scope',
        'character_weapon4_attack',
        'character_weapon4_attack_b',
        'character_weapon4_fumble',
        'character_weapon4_damage',
        'character_weapon4_dices',
        'character_weapon4_critic',
        'character_weapon4_face',
        'character_weapon4_flank',
        'character_weapon4_back',
        'character_weapon4_value',
        'character_weapon5_name',
        'character_weapon5_type',
        'character_weapon5_scope',
        'character_weapon5_attack',
        'character_weapon5_attack_b',
        'character_weapon5_fumble',
        'character_weapon5_damage',
        'character_weapon5_dices',
        'character_weapon5_critic',
        'character_weapon5_face',
        'character_weapon5_flank',
        'character_weapon5_back',
        'character_weapon5_value',
        'character_armor1_name',
        'character_armor1_piercing',
        'character_armor1_edge',
        'character_armor1_blunt',
        'character_armor1_fire',
        'character_armor1_spell',
        'character_armor1_clutter',
        'character_armor1_magic',
        'character_armor1_value',
        'character_armor2_name',
        'character_armor2_piercing',
        'character_armor2_edge',
        'character_armor2_blunt',
        'character_armor2_fire',
        'character_armor2_spell',
        'character_armor2_clutter',
        'character_armor2_magic',
        'character_armor2_value',
        'character_armor3_name',
        'character_armor3_piercing',
        'character_armor3_edge',
        'character_armor3_blunt',
        'character_armor3_fire',
        'character_armor3_spell',
        'character_armor3_clutter',
        'character_armor3_magic',
        'character_armor3_value',
        'character_shield_type',
        'character_shield_physic',
        'character_shield_field',
        'character_shield_face',
        'character_shield_flank',
        'character_shield_back',
        'character_shield_value',
        'character_equipped_spellbook',
        'character_equipped_spellbook_value',
        'character_equipped_symbol',
        'character_equipped_symbol_value',
        'character_tma_alcool',
        'character_tma_alcool_b',
        'character_tma_arts&crafts',
        'character_tma_arts&crafts_b',
        'character_tma_carpentry',
        'character_tma_carpentry_b',
        'character_tma_hunting&fishing',
        'character_tma_hunting&fishing_b',
        'character_tma_drive',
        'character_tma_drive_b',
        'character_tma_strings',
        'character_tma_strings_b',
        'character_tma_run',
        'character_tma_run_b',
        'character_tma_balanced',
        'character_tma_balanced_b',
        'character_tma_horseriding',
        'character_tma_horseriding_b',
        'character_tma_climbing',
        'character_tma_climbing_b',
        'character_tma_fight',
        'character_tma_fight_b',
        'character_tma_metallurgy',
        'character_tma_metallurgy_b',
        'character_tma_swimming',
        'character_tma_swimming_b',
        'character_tma_navigation',
        'character_tma_navigation_b',
        'character_tma_torture',
        'character_tma_torture_b',
        'character_tma_dragonry',
        'character_tma_dragonry_b',
        'character_tha_acrobatics',
        'character_tha_acrobatics_b',
        'character_tha_naturecamo',
        'character_tha_naturecamo_b',
        'character_tha_urbancamo',
        'character_tha_urbancamo_b',
        'character_tha_lockpicking',
        'character_tha_lockpicking_b',
        'character_tha_disguise',
        'character_tha_disguise_b',
        'character_tha_demolition',
        'character_tha_demolition_b',
        'character_tha_discretnature',
        'character_tha_discretnature_b',
        'character_tha_discreturban',
        'character_tha_discreturban_b',
        'character_tha_concealment',
        'character_tha_concealment_b',
        'character_tha_medecine',
        'character_tha_medecine_b',
        'character_tha_trap',
        'character_tha_trap_b',
        'character_tha_precision',
        'character_tha_precision_b',
        'character_tha_technology',
        'character_tha_technology_b',
        'character_tha_thanatology',
        'character_tha_thanatology_b',
        'character_tha_pickpocketing',
        'character_tha_pickpocketing_b',
        'character_tha_tribaltattoo',
        'character_tha_tribaltattoo_b',
        'character_tse_analysis',
        'character_tse_analysis_b',
        'character_tse_concentration',
        'character_tse_concentration_b',
        'character_tse_cook',
        'character_tse_cook_b',
        'character_tse_detection',
        'character_tse_detection_b',
        'character_tse_dressage',
        'character_tse_dressage_b',
        'character_tse_listen',
        'character_tse_listen_b',
        'character_tse_evaluation',
        'character_tse_evaluation_b',
        'character_tse_lipreading',
        'character_tse_lipreading_b',
        'character_tse_meteorology',
        'character_tse_meteorology_b',
        'character_tse_observation',
        'character_tse_observation_b',
        'character_tse_smell',
        'character_tse_smell_b',
        'character_tse_orientation',
        'character_tse_orientation_b',
        'character_tse_perception',
        'character_tse_perception_b',
        'character_tse_tracking',
        'character_tse_tracking_b',
        'character_tse_research',
        'character_tse_research_b',
        'character_tse_pes',
        'character_tse_pes_b',
        'character_tso_spiel',
        'character_tso_spiel_b',
        'character_tso_corruption',
        'character_tso_corruption_b',
        'character_tso_eloquence',
        'character_tso_eloquence_b',
        'character_tso_empathy',
        'character_tso_empathy_b',
        'character_tso_counterfeiting',
        'character_tso_counterfeiting_b',
        'character_tso_hypnotism',
        'character_tso_hypnotism_b',
        'character_tso_intimidation',
        'character_tso_intimidation_b',
        'character_tso_secretjargon',
        'character_tso_secretjargon_b',
        'character_tso_game',
        'character_tso_game_b',
        'character_tso_leadership',
        'character_tso_leadership_b',
        'character_tso_bargaining',
        'character_tso_bargaining_b',
        'character_tso_performance',
        'character_tso_performance_b',
        'character_tso_rumors',
        'character_tso_rumors_b',
        'character_tso_seduction',
        'character_tso_seduction_b',
        'character_tso_ventriloquism',
        'character_tso_ventriloquism_b',
        'character_tso_ignisalta',
        'character_tso_ignisalta_b',
        'character_tco_ancientcult',
        'character_tco_ancientcult_b',
        'character_tco_astronomy',
        'character_tco_astronomy_b',
        'character_tco_library',
        'character_tco_library_b',
        'character_tco_creature',
        'character_tco_creature_b',
        'character_tco_geography',
        'character_tco_geography_b',
        'character_tco_history',
        'character_tco_history_b',
        'character_tco_identification',
        'character_tco_identification_b',
        'character_tco_houses',
        'character_tco_houses_b',
        'character_tco_nature',
        'character_tco_nature_b',
        'character_tco_occultism',
        'character_tco_occultism_b',
        'character_tco_politics',
        'character_tco_politics_b',
        'character_tco_ritualofdeath',
        'character_tco_ritualofdeath_b',
        'character_tco_spell',
        'character_tco_spell_b',
        'character_tco_tactical',
        'character_tco_tactical_b',
        'character_tco_theology',
        'character_tco_theology_b',
        'character_tco_ritualofstars',
        'character_tco_ritualofstars_b',
        'character_influence_meraltor',
        'character_influence_aravas',
        'character_influence_clergy',
        'character_influence_berrouve',
        'character_influence_harlog',
        'character_influence_brotherhood',
        'character_influence_duloir',
        'character_influence_tiar',
        'character_influence_wolfcircle',
        'character_influence_arcadis',
        'character_influence_komeidai',
        'character_influence_savie',
        'character_influence_mortuterra',
        'character_influence_collectorsguild',
        'character_influence_total',
        'character_background',
        'character_injury1_name',
        'character_injury1_descr',
        'character_injury1_year',
        'character_injury1_month',
        'character_injury1_day',
        'character_injury2_name',
        'character_injury2_descr',
        'character_injury2_year',
        'character_injury2_month',
        'character_injury2_day',
        'character_injury3_name',
        'character_injury3_descr',
        'character_injury3_year',
        'character_injury3_month',
        'character_injury3_day',
        'character_injury4_name',
        'character_injury4_descr',
        'character_injury4_year',
        'character_injury4_month',
        'character_injury4_day',
        'character_injury5_name',
        'character_injury5_descr',
        'character_injury5_year',
        'character_injury5_month',
        'character_injury5_day',
        'character_injury6_name',
        'character_injury6_descr',
        'character_injury6_year',
        'character_injury6_month',
        'character_injury6_day',
        'character_injury7_name',
        'character_injury7_descr',
        'character_injury7_year',
        'character_injury7_month',
        'character_injury7_day',
        'character_injury8_name',
        'character_injury8_descr',
        'character_injury8_year',
        'character_injury8_month',
        'character_injury8_day',
        'character_scar1_name',
        'character_scar1_descr',
        'character_scar1_year',
        'character_scar1_month',
        'character_scar1_day',
        'character_scar2_name',
        'character_scar2_descr',
        'character_scar2_year',
        'character_scar2_month',
        'character_scar2_day',
        'character_scar3_name',
        'character_scar3_descr',
        'character_scar3_year',
        'character_scar3_month',
        'character_scar3_day',
        'character_scar4_name',
        'character_scar4_descr',
        'character_scar4_year',
        'character_scar4_month',
        'character_scar4_day',
        'character_scar5_name',
        'character_scar5_descr',
        'character_scar5_year',
        'character_scar5_month',
        'character_scar5_day',
        'character_scar6_name',
        'character_scar6_descr',
        'character_scar6_year',
        'character_scar6_month',
        'character_scar6_day',
        'character_scar7_name',
        'character_scar7_descr',
        'character_scar7_year',
        'character_scar7_month',
        'character_scar7_day',
        'character_scar8_name',
        'character_scar8_descr',
        'character_scar8_year',
        'character_scar8_month',
        'character_scar8_day',
        'character_deco1_name',
        'character_deco1_descr',
        'character_deco1_year',
        'character_deco1_month',
        'character_deco1_day',
        'character_deco2_name',
        'character_deco2_descr',
        'character_deco2_year',
        'character_deco2_month',
        'character_deco2_day',
        'character_deco3_name',
        'character_deco3_descr',
        'character_deco3_year',
        'character_deco3_month',
        'character_deco3_day',
        'character_deco4_name',
        'character_deco4_descr',
        'character_deco4_year',
        'character_deco4_month',
        'character_deco4_day',
        'character_deco5_name',
        'character_deco5_descr',
        'character_deco5_year',
        'character_deco5_month',
        'character_deco5_day',
        'character_deco6_name',
        'character_deco6_descr',
        'character_deco6_year',
        'character_deco6_month',
        'character_deco6_day',
        'character_deco7_name',
        'character_deco7_descr',
        'character_deco7_year',
        'character_deco7_month',
        'character_deco7_day',
        'character_deco8_name',
        'character_deco8_descr',
        'character_deco8_year',
        'character_deco8_month',
        'character_deco8_day',

    ];
}

voici ma migration pour le character

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCharacterTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('characters', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id');
            $table->string('character_name')->unique();
            $table->Integer('character_age')->nullable();
            $table->string('character_title')->nullable();
            $table->Integer('character_date_of_birth')->nullable();
            $table->Integer('character_month_of_birth')->nullable();
            $table->bigInteger('character_year_of_birth')->nullable();
            $table->bigInteger('character_experience')->nullable();
            $table->bigInteger('character_essence_game')->nullable();
            $table->bigInteger('character_essence_total')->nullable();

            $table->string('character_house_name')->nullable();
            $table->string('character_house_rank')->nullable();
            $table->string('character_house_dogma')->nullable();

            $table->string('character_guild_name')->nullable();
            $table->string('character_guild_dogma')->nullable();

            $table->string('character_career_name')->nullable();

            $table->Integer('character_career_physic')->nullable();
            $table->Integer('character_career_physic_bonus')->nullable();
            $table->Integer('character_career_physic_penalty')->nullable();

            $table->Integer('character_career_mental')->nullable();
            $table->Integer('character_career_mental_bonus')->nullable();
            $table->Integer('character_career_mental_penalty')->nullable();

            $table->Integer('character_career_reaction')->nullable();
            $table->Integer('character_career_reaction_bonus')->nullable();
            $table->Integer('character_career_reaction_penalty')->nullable();

            $table->bigInteger('character_life_point_max')->nullable();
            $table->bigInteger('character_life_point_game')->nullable();
            $table->bigInteger('character_life_point_bonus')->nullable();
            $table->bigInteger('character_life_point_percentage_bonus')->nullable();

            $table->bigInteger('character_magic_point_max')->nullable();
            $table->bigInteger('character_magic_point_game')->nullable();
            $table->bigInteger('character_magic_point_bonus')->nullable();
            $table->bigInteger('character_magic_point_percentage_bonus')->nullable();

            $table->bigInteger('character_magic_force_arcana_max')->nullable();
            $table->bigInteger('character_magic_force_arcana_game')->nullable();
            $table->bigInteger('character_magic_force_arcana_bonus')->nullable();
            $table->bigInteger('character_magic_force_arcana_percentage_bonus')->nullable();

            $table->bigInteger('character_magic_force_holy_max')->nullable();
            $table->bigInteger('character_magic_force_holy_game')->nullable();
            $table->bigInteger('character_magic_force_holy_bonu')->nullable();
            $table->bigInteger('character_magic_force_holy_percentage_bonus')->nullable();

            $table->bigInteger('character_magic_force_cursed_max')->nullable();
            $table->bigInteger('character_magic_force_cursed_game')->nullable();
            $table->bigInteger('character_magic_force_cursed_bonus')->nullable();
            $table->bigInteger('character_magic_force_cursed_percentage_bonus')->nullable();

            $table->bigInteger('character_gold')->nullable();
            $table->bigInteger('character_bank')->nullable();
            $table->Integer('character_lap_speed')->nullable();

            $table->Integer('character_movement')->nullable();
            $table->Integer('character_movement_bonus_humanTerritory')->nullable();
            $table->Integer('character_movement_bonus_inside')->nullable();
            $table->Integer('character_movement_bonus_savageTerritory')->nullable();
            $table->Integer('character_movement_bonus_naval')->nullable();
            $table->Integer('character_movement_bonus_mount')->nullable();

            $table->Integer('character_fields')->nullable();
            $table->Integer('character_fields_bonus_spell')->nullable();

            $table->string('character_weapon1_name')->nullable();
            $table->string('character_weapon1_type')->nullable();
            $table->Integer('character_weapon1_scope')->nullable();
            $table->Integer('character_weapon1_attack')->nullable();
            $table->Integer('character_weapon1_attack_b')->nullable();
            $table->Integer('character_weapon1_fumble')->nullable();
            $table->Integer('character_weapon1_damage')->nullable();
            $table->string('character_weapon1_dices')->nullable();
            $table->bigInteger('character_weapon1_critic')->nullable();
            $table->Integer('character_weapon1_face')->nullable();
            $table->Integer('character_weapon1_flank')->nullable();
            $table->Integer('character_weapon1_back')->nullable();
            $table->bigInteger('character_weapon1_value')->nullable();

            $table->string('character_weapon2_name')->nullable();
            $table->string('character_weapon2_type')->nullable();
            $table->Integer('character_weapon2_scope')->nullable();
            $table->Integer('character_weapon2_attack')->nullable();
            $table->Integer('character_weapon2_attack_b')->nullable();
            $table->Integer('character_weapon2_fumble')->nullable();
            $table->Integer('character_weapon2_damage')->nullable();
            $table->string('character_weapon2_dices')->nullable();
            $table->bigInteger('character_weapon2_critic')->nullable();
            $table->Integer('character_weapon2_face')->nullable();
            $table->Integer('character_weapon2_flank')->nullable();
            $table->Integer('character_weapon2_back')->nullable();
            $table->bigInteger('character_weapon2_value')->nullable();

            $table->string('character_weapon3_name')->nullable();
            $table->string('character_weapon3_type')->nullable();
            $table->Integer('character_weapon3_scope')->nullable();
            $table->Integer('character_weapon3_attack')->nullable();
            $table->Integer('character_weapon3_attack_b')->nullable();
            $table->Integer('character_weapon3_fumble')->nullable();
            $table->Integer('character_weapon3_damage')->nullable();
            $table->string('character_weapon3_dices')->nullable();
            $table->bigInteger('character_weapon3_critic')->nullable();
            $table->Integer('character_weapon3_face')->nullable();
            $table->Integer('character_weapon3_flank')->nullable();
            $table->Integer('character_weapon3_back')->nullable();
            $table->bigInteger('character_weapon3_value')->nullable();

            $table->string('character_weapon4_name')->nullable();
            $table->string('character_weapon4_type')->nullable();
            $table->Integer('character_weapon4_scope')->nullable();
            $table->Integer('character_weapon4_attack')->nullable();
            $table->Integer('character_weapon4_attack_b')->nullable();
            $table->Integer('character_weapon4_fumble')->nullable();
            $table->Integer('character_weapon4_damage')->nullable();
            $table->string('character_weapon4_dices')->nullable();
            $table->bigInteger('character_weapon4_critic')->nullable();
            $table->Integer('character_weapon4_face')->nullable();
            $table->Integer('character_weapon4_flank')->nullable();
            $table->Integer('character_weapon4_back')->nullable();
            $table->bigInteger('character_weapon4_value')->nullable();

            $table->string('character_weapon5_name')->nullable();
            $table->string('character_weapon5_type')->nullable();
            $table->Integer('character_weapon5_scope')->nullable();
            $table->Integer('character_weapon5_attack')->nullable();
            $table->Integer('character_weapon5_attack_b')->nullable();
            $table->Integer('character_weapon5_fumble')->nullable();
            $table->Integer('character_weapon5_damage')->nullable();
            $table->string('character_weapon5_dices')->nullable();
            $table->bigInteger('character_weapon5_critic')->nullable();
            $table->Integer('character_weapon5_face')->nullable();
            $table->Integer('character_weapon5_flank')->nullable();
            $table->Integer('character_weapon5_back')->nullable();
            $table->bigInteger('character_weapon5_value')->nullable();

            $table->string('character_armor1_name')->nullable();
            $table->Integer('character_armor1_piercing')->nullable();
            $table->Integer('character_armor1_edge')->nullable();
            $table->Integer('character_armor1_blunt')->nullable();
            $table->Integer('character_armor1_fire')->nullable();
            $table->Integer('character_armor1_spell')->nullable();
            $table->Integer('character_armor1_clutter')->nullable();
            $table->Integer('character_armor1_magic')->nullable();
            $table->bigInteger('character_armor1_value')->nullable();

            $table->string('character_armor2_name')->nullable();
            $table->Integer('character_armor2_piercing')->nullable();
            $table->Integer('character_armor2_edge')->nullable();
            $table->Integer('character_armor2_blunt')->nullable();
            $table->Integer('character_armor2_fire')->nullable();
            $table->Integer('character_armor2_spell')->nullable();
            $table->Integer('character_armor2_clutter')->nullable();
            $table->Integer('character_armor2_magic')->nullable();
            $table->bigInteger('character_armor2_value')->nullable();

            $table->string('character_armor3_name')->nullable();
            $table->Integer('character_armor3_piercing')->nullable();
            $table->Integer('character_armor3_edge')->nullable();
            $table->Integer('character_armor3_blunt')->nullable();
            $table->Integer('character_armor3_fire')->nullable();
            $table->Integer('character_armor3_spell')->nullable();
            $table->Integer('character_armor3_clutter')->nullable();
            $table->Integer('character_armor3_magic')->nullable();
            $table->bigInteger('character_armor3_value')->nullable();

            $table->string('character_shield_type')->nullable();
            $table->Integer('character_shield_physic')->nullable();
            $table->Integer('character_shield_field')->nullable();
            $table->Integer('character_shield_face')->nullable();
            $table->Integer('character_shield_flank')->nullable();
            $table->Integer('character_shield_back')->nullable();
            $table->bigInteger('character_shield_value')->nullable();

            $table->string('character_equipped_spellbook')->nullable();
            $table->bigInteger('character_equipped_spellbook_value')->nullable();

            $table->string('character_equipped_symbol')->nullable();
            $table->bigInteger('character_equipped_symbol_value')->nullable();

            $table->bigInteger('character_tma_alcool')->nullable();
            $table->Integer('character_tma_alcool_b')->nullable();
            $table->bigInteger('character_tma_arts&crafts')->nullable();
            $table->Integer('character_tma_arts&crafts_b')->nullable();
            $table->bigInteger('character_tma_carpentry')->nullable();
            $table->Integer('character_tma_carpentry_b')->nullable();
            $table->bigInteger('character_tma_hunting&fishing')->nullable();
            $table->Integer('character_tma_hunting&fishing_b')->nullable();
            $table->bigInteger('character_tma_drive')->nullable();
            $table->Integer('character_tma_drive_b')->nullable();
            $table->bigInteger('character_tma_strings')->nullable();
            $table->Integer('character_tma_strings_b')->nullable();
            $table->bigInteger('character_tma_run')->nullable();
            $table->Integer('character_tma_run_b')->nullable();
            $table->bigInteger('character_tma_balanced')->nullable();
            $table->Integer('character_tma_balanced_b')->nullable();
            $table->bigInteger('character_tma_horseriding')->nullable();
            $table->Integer('character_tma_horseriding_b')->nullable();
            $table->bigInteger('character_tma_climbing')->nullable();
            $table->Integer('character_tma_climbing_b')->nullable();
            $table->bigInteger('character_tma_fight')->nullable();
            $table->Integer('character_tma_fight_b')->nullable();
            $table->bigInteger('character_tma_metallurgy')->nullable();
            $table->Integer('character_tma_metallurgy_b')->nullable();
            $table->bigInteger('character_tma_swimming')->nullable();
            $table->Integer('character_tma_swimming_b')->nullable();
            $table->bigInteger('character_tma_navigation')->nullable();
            $table->Integer('character_tma_navigation_b')->nullable();
            $table->bigInteger('character_tma_torture')->nullable();
            $table->Integer('character_tma_torture_b')->nullable();
            $table->bigInteger('character_tma_dragonry')->nullable();
            $table->Integer('character_tma_dragonry_b')->nullable();

            $table->bigInteger('character_tha_acrobatics')->nullable();
            $table->Integer('character_tha_acrobatics_b')->nullable();
            $table->bigInteger('character_tha_naturecamo')->nullable();
            $table->Integer('character_tha_naturecamo_b')->nullable();
            $table->bigInteger('character_tha_urbancamo')->nullable();
            $table->Integer('character_tha_urbancamo_b')->nullable();
            $table->bigInteger('character_tha_lockpicking')->nullable();
            $table->Integer('character_tha_lockpicking_b')->nullable();
            $table->bigInteger('character_tha_disguise')->nullable();
            $table->Integer('character_tha_disguise_b')->nullable();
            $table->bigInteger('character_tha_demolition')->nullable();
            $table->Integer('character_tha_demolition_b')->nullable();
            $table->bigInteger('character_tha_discretnature')->nullable();
            $table->Integer('character_tha_discretnature_b')->nullable();
            $table->bigInteger('character_tha_discreturban')->nullable();
            $table->Integer('character_tha_discreturban_b')->nullable();
            $table->bigInteger('character_tha_concealment')->nullable();
            $table->Integer('character_tha_concealment_b')->nullable();
            $table->bigInteger('character_tha_medecine')->nullable();
            $table->Integer('character_tha_medecine_b')->nullable();
            $table->bigInteger('character_tha_trap')->nullable();
            $table->Integer('character_tha_trap_b')->nullable();
            $table->bigInteger('character_tha_precision')->nullable();
            $table->Integer('character_tha_precision_b')->nullable();
            $table->bigInteger('character_tha_technology')->nullable();
            $table->Integer('character_tha_technology_b')->nullable();
            $table->bigInteger('character_tha_thanatology')->nullable();
            $table->Integer('character_tha_thanatology_b')->nullable();
            $table->bigInteger('character_tha_pickpocketing')->nullable();
            $table->Integer('character_tha_pickpocketing_b')->nullable();
            $table->bigInteger('character_tha_tribaltattoo')->nullable();
            $table->Integer('character_tha_tribaltattoo_b')->nullable();

            $table->bigInteger('character_tse_analysis')->nullable();
            $table->Integer('character_tse_analysis_b')->nullable();
            $table->bigInteger('character_tse_concentration')->nullable();
            $table->Integer('character_tse_concentration_b')->nullable();
            $table->bigInteger('character_tse_cook')->nullable();
            $table->Integer('character_tse_cook_b')->nullable();
            $table->bigInteger('character_tse_detection')->nullable();
            $table->Integer('character_tse_detection_b')->nullable();
            $table->bigInteger('character_tse_dressage')->nullable();
            $table->Integer('character_tse_dressage_b')->nullable();
            $table->bigInteger('character_tse_listen')->nullable();
            $table->Integer('character_tse_listen_b')->nullable();
            $table->bigInteger('character_tse_evaluation')->nullable();
            $table->Integer('character_tse_evaluation_b')->nullable();
            $table->bigInteger('character_tse_lipreading')->nullable();
            $table->Integer('character_tse_lipreading_b')->nullable();
            $table->bigInteger('character_tse_meteorology')->nullable();
            $table->Integer('character_tse_meteorology_b')->nullable();
            $table->bigInteger('character_tse_observation')->nullable();
            $table->Integer('character_tse_observation_b')->nullable();
            $table->bigInteger('character_tse_smell')->nullable();
            $table->Integer('character_tse_smell_b')->nullable();
            $table->bigInteger('character_tse_orientation')->nullable();
            $table->Integer('character_tse_orientation_b')->nullable();
            $table->bigInteger('character_tse_perception')->nullable();
            $table->Integer('character_tse_perception_b')->nullable();
            $table->bigInteger('character_tse_tracking')->nullable();
            $table->Integer('character_tse_tracking_b')->nullable();
            $table->bigInteger('character_tse_research')->nullable();
            $table->Integer('character_tse_research_b')->nullable();
            $table->bigInteger('character_tse_pes')->nullable();
            $table->Integer('character_tse_pes_b')->nullable();

            $table->bigInteger('character_tso_spiel')->nullable();
            $table->Integer('character_tso_spiel_b')->nullable();
            $table->bigInteger('character_tso_corruption')->nullable();
            $table->Integer('character_tso_corruption_b')->nullable();
            $table->bigInteger('character_tso_eloquence')->nullable();
            $table->Integer('character_tso_eloquence_b')->nullable();
            $table->bigInteger('character_tso_empathy')->nullable();
            $table->Integer('character_tso_empathy_b')->nullable();
            $table->bigInteger('character_tso_counterfeiting')->nullable();
            $table->Integer('character_tso_counterfeiting_b')->nullable();
            $table->bigInteger('character_tso_hypnotism')->nullable();
            $table->Integer('character_tso_hypnotism_b')->nullable();
            $table->bigInteger('character_tso_intimidation')->nullable();
            $table->Integer('character_tso_intimidation_b')->nullable();
            $table->bigInteger('character_tso_secretjargon')->nullable();
            $table->Integer('character_tso_secretjargon_b')->nullable();
            $table->bigInteger('character_tso_game')->nullable();
            $table->Integer('character_tso_game_b')->nullable();
            $table->bigInteger('character_tso_leadership')->nullable();
            $table->Integer('character_tso_leadership_b')->nullable();
            $table->bigInteger('character_tso_bargaining')->nullable();
            $table->Integer('character_tso_bargaining_b')->nullable();
            $table->bigInteger('character_tso_performance')->nullable();
            $table->Integer('character_tso_performance_b')->nullable();
            $table->bigInteger('character_tso_rumors')->nullable();
            $table->Integer('character_tso_rumors_b')->nullable();
            $table->bigInteger('character_tso_seduction')->nullable();
            $table->Integer('character_tso_seduction_b')->nullable();
            $table->bigInteger('character_tso_ventriloquism')->nullable();
            $table->Integer('character_tso_ventriloquism_b')->nullable();
            $table->bigInteger('character_tso_ignisalta')->nullable();
            $table->Integer('character_tso_ignisalta_b')->nullable();

            $table->bigInteger('character_tco_ancientcult')->nullable();
            $table->Integer('character_tco_ancientcult_b')->nullable();
            $table->bigInteger('character_tco_astronomy')->nullable();
            $table->Integer('character_tco_astronomy_b')->nullable();
            $table->bigInteger('character_tco_library')->nullable();
            $table->Integer('character_tco_library_b')->nullable();
            $table->bigInteger('character_tco_creature')->nullable();
            $table->Integer('character_tco_creature_b')->nullable();
            $table->bigInteger('character_tco_geography')->nullable();
            $table->Integer('character_tco_geography_b')->nullable();
            $table->bigInteger('character_tco_history')->nullable();
            $table->Integer('character_tco_history_b')->nullable();
            $table->bigInteger('character_tco_identification')->nullable();
            $table->Integer('character_tco_identification_b')->nullable();
            $table->bigInteger('character_tco_houses')->nullable();
            $table->Integer('character_tco_houses_b')->nullable();
            $table->bigInteger('character_tco_nature')->nullable();
            $table->Integer('character_tco_nature_b')->nullable();
            $table->bigInteger('character_tco_occultism')->nullable();
            $table->Integer('character_tco_occultism_b')->nullable();
            $table->bigInteger('character_tco_politics')->nullable();
            $table->Integer('character_tco_politics_b')->nullable();
            $table->bigInteger('character_tco_ritualofdeath')->nullable();
            $table->Integer('character_tco_ritualofdeath_b')->nullable();
            $table->bigInteger('character_tco_spell')->nullable();
            $table->Integer('character_tco_spell_b')->nullable();
            $table->bigInteger('character_tco_tactical')->nullable();
            $table->Integer('character_tco_tactical_b')->nullable();
            $table->bigInteger('character_tco_theology')->nullable();
            $table->Integer('character_tco_theology_b')->nullable();
            $table->bigInteger('character_tco_ritualofstars')->nullable();
            $table->Integer('character_tco_ritualofstars_b')->nullable();

            $table->bigInteger('character_influence_meraltor')->nullable();
            $table->bigInteger('character_influence_aravas')->nullable();
            $table->bigInteger('character_influence_clergy')->nullable();
            $table->bigInteger('character_influence_berrouve')->nullable();
            $table->bigInteger('character_influence_harlog')->nullable();
            $table->bigInteger('character_influence_brotherhood')->nullable();
            $table->bigInteger('character_influence_duloir')->nullable();
            $table->bigInteger('character_influence_tiar')->nullable();
            $table->bigInteger('character_influence_wolfcircle')->nullable();
            $table->bigInteger('character_influence_arcadis')->nullable();
            $table->bigInteger('character_influence_komeidai')->nullable();
            $table->bigInteger('character_influence_savie')->nullable();
            $table->bigInteger('character_influence_mortuterra')->nullable();
            $table->bigInteger('character_influence_collectorsguild')->nullable();
            $table->bigInteger('character_influence_total')->nullable();


            $table->TEXT('character_background')->nullable();

            $table->string('character_injury1_name')->nullable();
            $table->TEXT('character_injury1_descr')->nullable();
            $table->BigInteger('character_injury1_year')->nullable();
            $table->Integer('character_injury1_month')->nullable();
            $table->Integer('character_injury1_day')->nullable();

            $table->string('character_injury2_name')->nullable();
            $table->TEXT('character_injury2_descr')->nullable();
            $table->BigInteger('character_injury2_year')->nullable();
            $table->Integer('character_injury2_month')->nullable();
            $table->Integer('character_injury2_day')->nullable();

            $table->string('character_injury3_name')->nullable();
            $table->TEXT('character_injury3_descr')->nullable();
            $table->BigInteger('character_injury3_year')->nullable();
            $table->Integer('character_injury3_month')->nullable();
            $table->Integer('character_injury3_day')->nullable();

            $table->string('character_injury4_name')->nullable();
            $table->TEXT('character_injury4_descr')->nullable();
            $table->BigInteger('character_injury4_year')->nullable();
            $table->Integer('character_injury4_month')->nullable();
            $table->Integer('character_injury4_day')->nullable();

            $table->string('character_injury5_name')->nullable();
            $table->TEXT('character_injury5_descr')->nullable();
            $table->BigInteger('character_injury5_year')->nullable();
            $table->Integer('character_injury5_month')->nullable();
            $table->Integer('character_injury5_day')->nullable();

            $table->string('character_injury6_name')->nullable();
            $table->TEXT('character_injury6_descr')->nullable();
            $table->BigInteger('character_injury6_year')->nullable();
            $table->Integer('character_injury6_month')->nullable();
            $table->Integer('character_injury6_day')->nullable();

            $table->string('character_injury7_name')->nullable();
            $table->TEXT('character_injury7_descr')->nullable();
            $table->BigInteger('character_injury7_year')->nullable();
            $table->Integer('character_injury7_month')->nullable();
            $table->Integer('character_injury7_day')->nullable();

            $table->string('character_injury8_name')->nullable();
            $table->TEXT('character_injury8_descr')->nullable();
            $table->BigInteger('character_injury8_year')->nullable();
            $table->Integer('character_injury8_month')->nullable();
            $table->Integer('character_injury8_day')->nullable();

            $table->string('character_scar1_name')->nullable();
            $table->TEXT('character_scar1_descr')->nullable();
            $table->BigInteger('character_scar1_year')->nullable();
            $table->Integer('character_scar1_month')->nullable();
            $table->Integer('character_scar1_day')->nullable();

            $table->string('character_scar2_name')->nullable();
            $table->TEXT('character_scar2_descr')->nullable();
            $table->BigInteger('character_scar2_year')->nullable();
            $table->Integer('character_scar2_month')->nullable();
            $table->Integer('character_scar2_day')->nullable();

            $table->string('character_scar3_name')->nullable();
            $table->TEXT('character_scar3_descr')->nullable();
            $table->BigInteger('character_scar3_year')->nullable();
            $table->Integer('character_scar3_month')->nullable();
            $table->Integer('character_scar3_day')->nullable();

            $table->string('character_scar4_name')->nullable();
            $table->TEXT('character_scar4_descr')->nullable();
            $table->BigInteger('character_scar4_year')->nullable();
            $table->Integer('character_scar4_month')->nullable();
            $table->Integer('character_scar4_day')->nullable();

            $table->string('character_scar5_name')->nullable();
            $table->TEXT('character_scar5_descr')->nullable();
            $table->BigInteger('character_scar5_year')->nullable();
            $table->Integer('character_scar5_month')->nullable();
            $table->Integer('character_scar5_day')->nullable();

            $table->string('character_scar6_name')->nullable();
            $table->TEXT('character_scar6_descr')->nullable();
            $table->BigInteger('character_scar6_year')->nullable();
            $table->Integer('character_scar6_month')->nullable();
            $table->Integer('character_scar6_day')->nullable();

            $table->string('character_scar7_name')->nullable();
            $table->TEXT('character_scar7_descr')->nullable();
            $table->BigInteger('character_scar7_year')->nullable();
            $table->Integer('character_scar7_month')->nullable();
            $table->Integer('character_scar7_day')->nullable();

            $table->string('character_scar8_name')->nullable();
            $table->TEXT('character_scar8_descr')->nullable();
            $table->BigInteger('character_scar8_year')->nullable();
            $table->Integer('character_scar8_month')->nullable();
            $table->Integer('character_scar8_day')->nullable();

            $table->string('character_deco1_name')->nullable();
            $table->TEXT('character_deco1_descr')->nullable();
            $table->BigInteger('character_deco1_year')->nullable();
            $table->Integer('character_deco1_month')->nullable();
            $table->Integer('character_deco1_day')->nullable();

            $table->string('character_deco2_name')->nullable();
            $table->TEXT('character_deco2_descr')->nullable();
            $table->BigInteger('character_deco2_year')->nullable();
            $table->Integer('character_deco2_month')->nullable();
            $table->Integer('character_deco2_day')->nullable();

            $table->string('character_deco3_name')->nullable();
            $table->TEXT('character_deco3_descr')->nullable();
            $table->BigInteger('character_deco3_year')->nullable();
            $table->Integer('character_deco3_month')->nullable();
            $table->Integer('character_deco3_day')->nullable();

            $table->string('character_deco4_name')->nullable();
            $table->TEXT('character_deco4_descr')->nullable();
            $table->BigInteger('character_deco4_year')->nullable();
            $table->Integer('character_deco4_month')->nullable();
            $table->Integer('character_deco4_day')->nullable();

            $table->string('character_deco5_name')->nullable();
            $table->TEXT('character_deco5_descr')->nullable();
            $table->BigInteger('character_deco5_year')->nullable();
            $table->Integer('character_deco5_month')->nullable();
            $table->Integer('character_deco5_day')->nullable();

            $table->string('character_deco6_name')->nullable();
            $table->TEXT('character_deco6_descr')->nullable();
            $table->BigInteger('character_deco6_year')->nullable();
            $table->Integer('character_deco6_month')->nullable();
            $table->Integer('character_deco6_day')->nullable();

            $table->string('character_deco7_name')->nullable();
            $table->TEXT('character_deco7_descr')->nullable();
            $table->BigInteger('character_deco7_year')->nullable();
            $table->Integer('character_deco7_month')->nullable();
            $table->Integer('character_deco7_day')->nullable();

            $table->string('character_deco8_name')->nullable();
            $table->TEXT('character_deco8_descr')->nullable();
            $table->BigInteger('character_deco8_year')->nullable();
            $table->Integer('character_deco8_month')->nullable();
            $table->Integer('character_deco8_day')->nullable();

            $table->timestamps();

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('characters');
    }
}

Donc ce que je désire, c'est que lors qu'un user créer un personnage, que ce personnage soit assossier à son compte (user_id)

Merci.

Posté il y a 4 mois
Avatar de CinquièmeDimension
CinquièmeDimension

Salut,

Peux-tu nous nous montrer ta migration de création du user, et to model user.php ?

Je ne comprends pas ce que tu veux faire avec ta route ... Tu veux forcer l'id à la création ?

Posté il y a 4 mois
Avatar de AlexandreCarignan
AlexandreCarignan

Voilà, j'ai édité mon message.

Ce que je désire, c'est que lors qu'un user créer un personnage, que ce personnage soit assossier à son compte (user_id).

Merci.

Posté il y a 4 mois
Avatar de CinquièmeDimension
CinquièmeDimension

En effet, c'est étrange.

Donc $request->input('user_id'); n'est pas reconnu ?

Il te reste la possibilité de ne pas passer par la vue et de l'injecter directement depuis le controller.

$data = $request->all();
$data['user_id'] = Auth::user()->id;
Character::create($data);
Posté il y a 4 mois
Avatar de AlexandreCarignan
AlexandreCarignan

Finalement, mon problème était ailleur, l'expérience entre tranquillement.

L'erreur se situait au niveau de mon modèle, j'avais oublié d'inclure user_id dans le protecter $fillable.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Character extends Model
{
    protected $fillable = [
        'user_id',  // il manquait ceci dans le modèle
        'character_name',
        'character_age',
        'character_title',

Un gros merci pour ton support. Alex.

Posté il y a 4 mois

Vous ne pouvez pas répondre à ce sujet.