Support the ongoing development of Laravel.io →
Database Views Blade

After loading the view with the columns, there are three opciones: add data, edit or remove current columns. To add more data to the current table i took the example of other views of this same website, but every time i push the add button, the website execute a query instead of showing the add view. I want the view to be loaded an then insert the data.

Code on routes.php

Route::get('/webcam/add', function()
{
	$chk = PlController::chkAdmin();

	if($chk == false){
		return Redirect::to('/login');
	}else{

		return View::make('admin.addwebcam');

	}

});

Route::get('/webcam/add', function()
{

	$chk = PlController::chkAdmin();

	if($chk == false){
		return Redirect::to('/login');
	}else{

		$nombre = Input::get('nombre');
		$edad = Input::get('edad');
		$ciudad = Input::get('ciudad');
		$pais = Input::get('pais');
		$telefono = Input::get('telefono');
		$mail = Input::get('mail');
		$mensaje = Input::get('mensaje');

		$webcam = new webcam;
		$webcam -> nombre = $nombre;
		$webcam -> ciudad = $ciudad;
		$webcam -> pais = $pais;
		$webcam ->  telefono = $telefono;
		$webcam -> mail = $mail;
		$webcam -> mensaje = $mensaje;

		$webcam->save();

		return Redirect::to('/webcam');

	}
});
Last updated 3 years ago.
0

Why do you have two of the same routes? You should only have one. It looks like the second one should be a post route, but it's hard to say without seeing the actual code that is triggering these routes.

Last updated 9 years ago.
0

thomastkim said:

Why do you have two of the same routes? You should only have one. It looks like the second one should be a post route, but it's hard to say without seeing the actual code that is triggering these routes.

I was following a example i had from other sections of the website. I want to send data from i form to the database. This is the view.

@extends('layouts.admin')
@section('content')
  {{ Form::open(array('url' => '/webcam/add', 'files' => true, 'method' => 'post')) }}
        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Nombre</label>
                        <div class="controls">
                          <input type="text" name="nombre" class="form-control">
                        </div>
                      </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Edad</label>
                        <div class="controls">
                          <input type="text" name="edad" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Ciudad</label>
                        <div class="controls">
                          <input type="text" name="ciudad" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Pais</label>
                        <div class="controls">
                          <input type="text" name="pais" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Telefono</label>
                        <div class="controls">
                          <input type="text" name="telefono" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
                <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Mail</label>
                        <div class="controls">
                          <input type="text" name="mail" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
         <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Mensaje</label>
                        <div class="controls">
                          <input type="text" name="mensaje" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Foto 1</label>
                        <div class="controls">
                          <input type="file" name="foto1" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
                    <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Foto 2</label>
                        <div class="controls">
                          <input type="file" name="foto2" class="form-control">
                        </div>
                      </div>
            </div>
        </div>
                    <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <label class="form-label">Foto 3</label>
                        <div class="controls">
                          <input type="file" name="foto3" class="form-control">
                        </div>
                      </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                      <div class="form-group">
                        <div class="controls">
                          <button type="submit"  class="btn btn-primary btn-cons">Publicar</a>
                        </div>
                      </div>
            </div>
        </div>

  {{ Form::close() }}

@stop

The other sections of the website works with the same kind of routing, so i was wondering why this is not working. This is an example of another adding route.


Route::get('/links/add', function()
{
	$chk = PlController::chkAdmin();

	if($chk == false){
		return Redirect::to('/login');
	}else{

		return View::make('admin.addlinks');

	}

});

Route::post('/links/add', function()
{
	$chk = PlController::chkAdmin();

	if($chk == false){
		return Redirect::to('/login');
	}else{
		$main = Input::file('imgmain');
		if($main)
		{
				$rand = str_random(10);
				$name = $rand.'.jpg';
				$main->move('/images', $name);

				$freako = new Articulo;
				$freako->fecha_articulos = time();
				$freako->fechaon_articulos = time();
				$freako->img1_articulos = $name;
				$freako->link_articulos = Input::get('link');
				$freako->titulo_articulos = Input::get('titulo');
				$freako->tipo_articulos = 3;
				$freako->texto_articulos = Input::get('subtitulo');
				$freako->save();

				return Redirect::to('/links');
		}
	}
});

Because of this, i dont know what im doing wrong.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Vault404 vault404 Joined 22 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.