app/Http/Controllers/NhanvatController.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)
    {
        $user = User::find($request->id);
        $nhanvat = Nhanvat::create([
            "name" => $request->name,
            "user_id" => $request->id
        ]);
        Nhanvat_votuong::create([
            "nhanvat_id" => $nhanvat->id,
            "votuong_id" => 1,
            "vitri" => 2,
        ]);
        Nhanvat_tranhinh::create([
            "nhanvat_id" => $nhanvat->id,
            "tranhinh_id" => 1,
            'active' => 1
        ]);
        return redirect('/home');
    }
public function store ( Request $ request ) { $ user = User :: find ( $ request -> id ) ; $ nhanvat = Nhanvat :: create ( [ " name " => $ request -> name , " user_id " => $ request -> id ] ) ; Nhanvat_votuong :: create ( [ " nhanvat_id " => $ nhanvat -> id , " votuong_id " => 1 , " vitri " => 2 , ] ) ; Nhanvat_tranhinh :: create ( [ " nhanvat_id " => $ nhanvat -> id , " tranhinh_id " => 1 , 'active' => 1 ] ) ; return redirect ( '/home' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .