1

routes.php

Route::post('admin/cm/{adres_id}/create', 'PugController@newEntrieAdd')->before('guest');
    Route::get('admin/cm/{adres_id}/new', 'PugController@newEntrie')->before('guest');

PugController

public function newEntrieAdd($adres_id){


        $mytime = date('Y-m-d');
        $scannedTime = date('Y-m-d H:i:s');

        DB::table('adres_gescand')
            ->where('adres_id', $adres_id)
            ->where('tijdstip', '>=' , $mytime)
            ->update(['actief' => 1, 'tijdstip' => $scannedTime]);


        return redirect('admin/lijstbeheeracv');

    }
// einde cm

// cm
public function newEntrie($adres_id){
    $entries = DB::table('adres_all')->get();

    return view('cm.bruggepost1', compact('entries'));
}

snippet of cm.bruggepost1

<form action="/cm/public/index.php/admin/cm/$adres_id/create" method="post" class="form-horizontal form-bordered">

What I want to do is when i go to /admin/cm/5/new I want to click on a button. And that will reffer to the snippet of cm.bruggepost1. But the problem is I can't find any way to use the variable (5 in here) in the cm.bruggepost. That $adres_id can be any number.

I hope someone can help me with explaining what I can do.

  • calling a method directly in controller from blade as Url http://stackoverflow.com/questions/27322854/laravel-call-method-from-view – Maytham Fahmi Aug 09 '15 at 19:29

1 Answers1

1

Assuming you're using Blade templates:

<form action="{{ url("admin/cm/$adres_id/create" }}" method="post" class="form-horizontal form-bordered">
Ben Claar
  • 3,285
  • 18
  • 33
  • @maytham Yeah, I was going to use that, but I was on my phone and feeling lazy -- feel free to edit my answer to add it. :p – Ben Claar Aug 10 '15 at 00:27