Kanchan186
1 month ago

ErrorException Invalid argument supplied for foreach()

Posted 1 month ago by Kanchan186

RegisterController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\country;
use App\state;
use App\city;
use App\register;
use App\user_hobby;

class RegisterController extends Controller
{
    public function adduser()
    {
               $country=country::get();
               $state=state::get();
               $city=city::get();
            

                      return view('register',compact('country','state','city'));
                  }

 public function store(Request $request)
    {
        //dd($request->all());
       
        register::create([
              
                    'name'=>request('name'),
                    'c_id'=>request('country'),
                    's_id'=>request('state'),
                    'ct_id'=>request('city'),
                    ]); 

               $country=country::get();
               $state=state::get();
               $city=city::get();
       return view('register',compact('country','state','city'));   
    }



 public function addhob()
    {
                $register=register::get();
               $user_hobby=user_hobby::get();
            

                      return view('addhob',compact('register','user_hobby'));

                  }


 public function store1(Request $request)
    {
        //dd($request->all());
        foreach(request('hob') as $hob_id) 
         {
             user_hobbies::create([
              'u_id'=> request('u_id'),
              'h_id'=> $hob_id,
            ]);
        }
    
         $register=register::get();
         $user_hobby=user_hobby::get();
         

         array($request->get('h_id'));


        return view('addhob',compact('register','user_hobby'));
    }



}

Please sign in or create an account to participate in this conversation.