I am redirecting users from one laravel website to another for single authentication.
This is the redirect code in the website 1
return Redirect::to('http://example.com/login?param1=paramValue');
In website 2, I'm trying to get value of param1
$param1 = Input::get('param1');
but get() function is not returning the value.
IF I try Input::has('param1') , it returns false.
Can someone please guide me on what's going wrong with my code?
The code is working fine for me,
$param1 = Input::get('param1');
return $param1;
Just try to update your framework using composer update
Related
Right now i am working on a Codeigniter project in which I am sending a link to the user to update their password, every thing is working according to the plan. Now all I need to know is that how can I extract data from URL that the user is following to update password.
Example:
http://localhost/ciauth/user/password_reset/user#gmail.com/6f1bb1aeba261e92c390ac28d85267767038703e
I want to extract the code after the E-mail ID.
Never mind i have solved it doing
$url_code=$this->uri->segment(4);
This is okay. But it will be better if you implement it with your action function:
public function password_reset($email, $code){
// $email: user#gmail.com
// $code: 6f1bb1aeba261e92c390ac28d85267767038703e
}
Try this, From this you can do extract full url, Place below code to your password_reset() to see your url extraction
echo'<pre>';print_r($this->uri->segment_array());die;
Never mind i have solved it doing
$url_code=$this->uri->segment(4);
I'm trying to implement a displayPerPage (10, 25, 50, etc.) when displaying a list of results on an index page. However i'm having a hard time how to just append that to the url without replacing the other query strings.
Example:
I have a paginator to switch pages however, if i'm on page 5 for example and select display per page 10 results on my select dropdown, it will load the results but erase the page=5 from the url. How to I just append displayPerPage without erasing where I currently am on the paginator.
Thanks for any help.
I know its possible to do it without creating a custom paginator since I have done it on another project with laravel 4, but that was a while back and I can't seem to figure out how to do it again.
Assuming $objects is the list of the item you're paginating, on your view you can add your paginator like that:
{{$objects->appends(request()->query())->links()}}
and query strings like your requestPerPage will be carried
After battling with this issue, I wrote a url parser helper function in php to to find and replace certain things in url after the ? sign (query part)
//for displayPerPage, orderBy and sortBy parse the url and replace with new values
function urlQueryParse($queryToReplace, $newValue){
// extract query from url
$fullUrl = Request::fullUrl();
if(strpos($fullUrl, '?') !== false){
//find everything after the ? in url
$url = substr($fullUrl, strpos($fullUrl, "?") + 1);
// check url to make sure $queryToReplace exists in the url
if(strpos($url, $queryToReplace) !== false) {
// look through the remaining url query and replace whats given to the function
$newUrL = preg_replace('/('. $queryToReplace. '\=)([^&]+)/', $queryToReplace.'='.$newValue, $url);
return Request::url()."?{$newUrL}";
}
// if the ? exists but the queryToReplace is not in the url, then add it to the query string
return Request::url()."?{$url}&{$queryToReplace}={$newValue}";
}
//if the url doesnt have ? sign then simply insert the new value
return Request::url()."?{$queryToReplace}={$newValue}";
}
Hopefully this helps someone. If you have any ides of how to improve it, I'm open to suggestions.
P.S. I'm working on Laravel 5.2
So I have the following scenario:
A user recharges his account via Adyen API and when the payment is processed I have a ProcessOrder method that receives the callback and does the following:
public function ProcessOrder($order)
{
//some order processing
$order_total = Yii::app()->db->createCommand()
->select('sum(`amount`) as total')
->from('`order_table`')
->where('`uid` = ' . $order->user->id)
->queryRow();
//send email with data
}
And I know the $order_total is failing but I don't know why...
I want to check logs but I don't know where they are (I'm new to this project) and I am trying to send me a email with the result. I cannot var_dump() the result and then die() because the class method is called via Adyen callback...
So basically my question is:
Where are the logs in a yii app OR
Why is the query failing? :-?
More Info
This class is the Order Module file under protected.
The var $order->user->id has the correct value, I checked this with email :D
I also tried foreach($order_total as $row) { //send result } and nothing... It's like the system does not have access to perform query s in that part
Please ask in comments if more information is needed
:)) This is stupid...
So I figured out why this does NOT work and the problem is this:
order_table and uid MUST NOT HAVE apostrophes ``! Without them, the query executes and everything works fine.
And yii app logs are in runtime folder :)
(And for those of you new to Yii and what to know how to call something from a query like this, the value is is $order_total['total'])*
Right now I'm trying to learn and test Laravel 4, and I have a little concern about script.
I wanted to insert information into the database, then redirect to the index page; the problem is that when I refresh the page, it displays the message to resend.
Here is the code I use:
public function store()
{
$new_cat = new Cat;
$new_cat->name = Input::get('new_cat');
$new_cat->age = Input::get('age_cat');
$new_cat->save();
return Redirect::action('CatsController#index');
}
The correct way to handle a POST request with a redirect is to issue a 303 status code.
http://en.wikipedia.org/wiki/HTTP_303
Using your original code:
return Redirect::action('CatsController#index', array(), 303);
Or Ochi's:
return Redirect::to('route_name', 303)->withInput();
maybe that will work
return Redirect::to('route_name')->withInput();
Hey guys, I'm using Twitter's PHP API, called twitterlibphp, and it works well, but there's one thing that I need to be able to initiate, which is the linking of URLs and #username replies. I already have the function for this written up correctly (it is called clickable_link($text);) and have tested it successfully. I am not too familiar with parts of twitterlibphp (link goes to source code), and I am not sure where to put the function clickable_link() in order to make URLs and #username's clickable. I hope that is enough information, thanks a lot.
EDIT:
In addition, I would like only one status to come up in the function GetFriendsTimeline(), right now 20 come up, is there any easy way to limit it to one?
I would extend the Twitter class and put the functionality in my own getUserTimeline method.
class MyTwitter extends Twitter
{
public function getUserTimeline()
{
$result = parent::getUserTimeline();
// Your functionality ...
return $result;
}
}
You don't need to put clickable_link() in twitterlibphp. Instead, call it right before you output a status message. Example:
$twitter = new Twitter('username', 'password');
$result = $twitter->getUserTimeline();
... parse the $result XML here ...
echo 'Status : '.clickable_link($status);