app/Http/Controllers/ContactoController.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,$cliente_id,$json=null)
    {
        Contacto::create([
            'cliente_id'=>$cliente_id,
            'nombre'=>$request->get('nombre'),
            'apellido'=>$request->get('apellido'),
            'email'=>$request->get('email'),
            'telefono'=>$request->get('telefono'),
            'extension'=>$request->get('extension'),
            'cargo'=>$request->get('cargo'),
            'ciudad_id'=>$request->get('ciudad_id'),
            'oficina_id'=>$request->get('oficina_id')
        ]);
        if($request->is('api/*') || $json!=null) {
            $contactos=Contacto::where('cliente_id',$cliente_id)->orderBy('nombre')->get();
            return response()->json(compact('contactos'));
        }
        return redirect('cliente/'.$cliente_id);
    }
public function store ( Request $ request , $ cliente_id , $ json = null ) { Contacto :: create ( [ 'cliente_id' => $ cliente_id , 'nombre' => $ request -> get ( 'nombre' ) , 'apellido' => $ request -> get ( 'apellido' ) , 'email' => $ request -> get ( 'email' ) , 'telefono' => $ request -> get ( 'telefono' ) , 'extension' => $ request -> get ( 'extension' ) , 'cargo' => $ request -> get ( 'cargo' ) , 'ciudad_id' => $ request -> get ( 'ciudad_id' ) , 'oficina_id' => $ request -> get ( 'oficina_id' ) ] ) ; if ( $ request -> is ( 'api/*' ) || $ json != null ) { $ contactos = Contacto :: where ( 'cliente_id' , $ cliente_id ) -> orderBy ( 'nombre' ) -> get ( ) ; return response ( ) -> json ( compact ( 'contactos' ) ) ; } return redirect ( 'cliente/' . $ cliente_id ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .