Laravel Spatie Activity Log Ip Address Customize - laravel

I am using Laravel Spatie Activity Log package in my laravel application.
I could customize in each module.
public function tapActivity(Activity $activity, string $eventName)
{
$activity->description = "Category is {$eventName}. ";
$activity->os = getOS();// custom hlper
}
This problem was when I was going to save ip.
$activity->ip = $request->ip();
I think above field should be added.
But where can we get $request ?

I solved this myself.
$activity->ip = request()->ip();
This just worked. :)

Related

Notifynder 3.1 on Laravel no result

I have installed Notifynder 3.1 inside my laravel app, for try if it works I have just insert one notification :
$from_user_id = 1;
$to_user_id = 2;
Notifynder::category('hello')
->from($from_user_id)
->to($to_user_id)
->url('http://www.yourwebsite.com/page')
->send();
It works properly, if I check inside database notification is there.
The problem happens when I try to get the notification in that way:
$user = User::find(2);
dd($user->getNotifications($limit = 10, $paginate = 1, $order = 'desc'));
The result is that:
Notification result
The result is empty, but in database notification exist
Notification Table
can anyone help me ?
Can you confirm have this in your app/User.php:
use Fenos\Notifynder\Notifable;
class User extends Model
{
use Notifable;
}
i found the problem, and i solve it.
if you changed the users primary key, then in vendor\fenos\notifynder\src\Notifynder\Notifable.php
change this $this->id to this $this->getKey().

How to register a user via json from ionic app to symfony2

How can I register a user from an ionic app via json at my backend.
My backend is build with symfony2 and fos userbundle.
I implemented authentication/authorization via json web token which works seamless.
But I don't know how to register a user and write him through my user entity to the database.
Can anyone give my a approach on hopw to realize this or much better anyone has a little example for this issue.
thanks in advance
bambamboole
edit:
i've created a repository # github:
https://github.com/bambamboole/symfony-jwt
Here a simple example to register a user from an AJAX call using FOSRest and FOSUser bundles :
public function postUserAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$parameters = $request->request->all();
$user = new User();
$user->setUsername($parameters["username"]);
$user->setEmail($parameters["mail"]);
$user->setPlainPassword($parameters["password"]);
$user->setEnabled(false);
$user->setFirstname($parameters["firstname"]);
$user->setLastname($parameters["lastname"]);
$tokenGenerator = $this->get('fos_user.util.token_generator');
$token = $tokenGenerator->generateToken();
$user->setConfirmationToken($token);
$em->persist($user);
$em->flush();
$this->get('fos_user.mailer')->sendConfirmationEmailMessage($user);
$view = View::create()
->setStatusCode(200)
->setData($user);
return $this->get('fos_rest.view_handler')->handle($view);
}
Hope it will help you.

How to disable password reminder email in Laravel

I'd like the Password::remind method to respond with the token and not send email to the email address provided. Can I suppress/disable email?
help would be much appreciated.
I don't think you can, the best you can do is to make one yourself, using Laravel's way of doing it:
Create a new class:
<?php
use Illuminate\Auth\Reminders\DatabaseReminderRepository as DbRepository;
class Reminder {
public static function create($user)
{
$reminders = new DbRepository(DB::connection(), Config::get('auth.reminder.table'), Config::get('app.key'));
return $reminders->create( $user );
}
}
And use it
$user = User::find(2);
echo Reminder::create($user);
After that you can check your password_reminders table, you new token will be there:
select * from password_reminders;

magento pass variable from controller to another model

I want to send custom mail through smtp.For which I installed http://www.magentocommerce.com/magento-connect/aschroder-com-smtp-pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html.
Which works properly for every mail provided by magento as default.
Now since the admin is having mail Id of google apps , my custom mail is not received by admin.So for this reason I want to Integrate my controller with the sending mail function of ashrodder extension.
My Controller code:
$frm = 'mail#domainname.com';
$to = 'admin#domainname.com';
$subject = "UPDATE";
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom($frm, 'Admin')
->addTo($to, 'Site Admin')
->setSubject($subject);
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Mail sent successfully.');
}
catch(Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send email.');
}
My question is simple : How should I pass [to,from,body] variable to any other model/controller ?
Please Help .Thanks in Advance
I think overriding the extensions controller would be the best solution.Check this link How to extend a controller

Magento - Use Short description for Google base description

I am using magento and it's built in functionality for adding products to google base. I would like to change it so that it uses the Short description as the Description in Google base. As opposed to the detailed description.
According to this Screencast you should be able to setup attribute attribute mappings. Is that not working for you?
Looking deeper, I don't have a google base account, so I can't test this, BUT, when I search through the Google Base module it looks like this is where it's grabbing the description
app/code/core/Mage/GoogleBase/Model/Service/Item.php
protected function _setUniversalData()
{
//...
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getDescription() );
$entry->setContent($content);
}
//...
}
My general approach here would be to create an override for the _setUniversalData method on the Mage_GoogleBase_Model_Service_Item class that looks something like this
protected function _setUniversalData()
{
parent::_setUniversalData();
//your code to parse through this object, find the long desription,
//and replace with the short. The following is pseudo code and just
//a guess at what would work
$service = $this->getService();
$object = $this->getObject();
$entry = $this->getEntry();
$new_text = $object->getShortDescription(); //not sure on getter method
$content = $service->newContent()->setText( $new_text );
$entry->setContent($content);
return $this;
}
Good luck!
Figured out all I had to do was change:
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getDescription() );
$entry->setContent($content);
}
to
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getShortDescription() );
$entry->setContent($content);
}
in app/code/core/Mage/GoogleBase/Model/Service/Item.php
I eventually got the module to work and managed to fix all errors.
I put together short step-by-step guide on how to set up the Magento Google Base feed, including account configuration, adding the condition attribute & mapping attributes and publishing them here http://blog.pod1.com/e-commerce/magento-google-base-feed/
Magento 1.7.0.2 Google Shopping 1.7.0.0
app/code/core/Mage/GoogleShopping/Model/Attribute/Content.php
Change $description = $this->getGroupAttributeDescription();
In $description = $this->getGroupAttributeShortDescription();

Resources