dimanche 27 décembre 2015

Access URL paramters - AngularJS and Laravel

So in ugly old fashioned php if I wanted to get a url param I would simply do this;

<?php $param = $_GET['id']; ?>

and to pass it to my Angular in the same page I would do this;

$scope.param = <?php echo json_encode($param); ?>;

I'm migrating my site to use Laravel and this way of obtaining params doesnt work.

Any idea how I can achieve this?

I would like to be able to extract params from links like this http://ift.tt/1VllTFv

Another issue I'm facing all because of my old code is that sometimes in my views I perform something like below;

$query = "SELECT * FROM users WHERE token='$token'";
$result = mysqli_query($connection, $query);
$count = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);

if ($token != $row['token']) {
    header("Location: password-link-invalid.html");
    exit;
}

With this is this something I can move to a middleware? If so can I simple include 'use DB' to use the DB facade inside the middleware.php

Cheers



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QUmXRy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire