app/Http/Controllers/StructuresController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $structure = Structure::create([
            'nom'      => $request->input('nom'),
            'form_jurid'      => $request->input('form_jurid'),
            'objet_social'      => $request->input('objet_social'),
            'raison_social'      => $request->input('raison_social'),
            'adresse'      => $request->input('adresse'),
            'tel'      => $request->input('tel'),
            'email'      => $request->input('email'),
            'grille_id'      => $request->input('grille_id'),
            'compte_id' => 0
        ]);
        $compte = Compte::create([
            'structure_id'      => $structure->id,
            'typecompte_id'     => $request->input('typecompte_id')
        ]);
        $structure->compte_id = $compte->id;
        $structure->save();
        if($structure || $compte){
            $personne = Personne::create([
                'structure_id'          => $structure->id,
                'nom'                   => $structure->nom,
                'datenaiss'             => now(),
                'email'                 => $structure->email
            ]);
            if($personne){
                $user = User::create([
                    'personne_id'       => $personne->id,
                    'name'              => $personne->nom,
                    'login'             => $personne->nom,
                    'email'             => $personne->email,
                    'password'          => Hash::make($request->input('password')),
                    'statut_user'       => 0
                ]);
                if($user){
                    $personne->user_id = $user->id;
                    $personne->save();
                    $compte->user_id = $user->id;
                    $compte->save();
                    return redirect('/home');
                }
            }
        }
    }
public function store ( Request $ request ) { $ structure = Structure :: create ( [ 'nom' => $ request -> input ( 'nom' ) , 'form_jurid' => $ request -> input ( 'form_jurid' ) , 'objet_social' => $ request -> input ( 'objet_social' ) , 'raison_social' => $ request -> input ( 'raison_social' ) , 'adresse' => $ request -> input ( 'adresse' ) , 'tel' => $ request -> input ( 'tel' ) , 'email' => $ request -> input ( 'email' ) , 'grille_id' => $ request -> input ( 'grille_id' ) , 'compte_id' => 0 ] ) ; $ compte = Compte :: create ( [ 'structure_id' => $ structure -> id , 'typecompte_id' => $ request -> input ( 'typecompte_id' ) ] ) ; $ structure -> compte_id = $ compte -> id ; $ structure -> save ( ) ; if ( $ structure || $ compte ) { $ personne = Personne :: create ( [ 'structure_id' => $ structure -> id , 'nom' => $ structure -> nom , 'datenaiss' => now ( ) , 'email' => $ structure -> email ] ) ; if ( $ personne ) { $ user = User :: create ( [ 'personne_id' => $ personne -> id , 'name' => $ personne -> nom , 'login' => $ personne -> nom , 'email' => $ personne -> email , 'password' => Hash :: make ( $ request -> input ( 'password' ) ) , 'statut_user' => 0 ] ) ; if ( $ user ) { $ personne -> user_id = $ user -> id ; $ personne -> save ( ) ; $ compte -> user_id = $ user -> id ; $ compte -> save ( ) ; return redirect ( '/home' ) ; } } } }
Store a newly created resource in storage.
Store a newly created resource in storage .