laravel url parameters code example
Example 1: laravel use url
use Illuminate\Support\Facades\URL;
echo URL::current();
Example 2: get value mentthod get laravel
Input::get('lastName') ;
//lastName is variable in view
Example 3: laravel url with parameters blade
url('path') . '?' . http_build_query(['param1' => 'value', 'param2' => 'value']);
Example 4: laravel get url parameters in controller
public function update($name)
{
User::where('name', $name)->first();
return view('test')->with('user', $user);
}
Example 5: laravel get url parameters in controller
Route::put('user/{name}', 'UserController@show');
Example 6: comment = Comment::find($this->route('comment')); in laravel
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onCascade('update')->onDelete('cascade');
$table->integer('post_id')->unsigned();
$table->foreign('post_id')->references('id')->on('users')->onCascade('update')->onDelete('cascade');
$table->text('comment');
$table->timestamps();
$table->rememberToken();
});