unioil-loyalty-app/app/Services/PasswordLogsService.php

70 lines
1.6 KiB
PHP

<?php
namespace App\Services;
use Response;
use Schema;
use Hash;
use Illuminate\Http\Request;
use App\Libraries\ListHelper;
use App\Contracts\PasswordLogsResourceInterface;
use App\PasswordLogs;
use App\Helpers\HttpStatusCode;
use App\Libraries\UuidHelper;
use App\Helpers\CurrentUserHelper;
class PasswordLogsService implements PasswordLogsResourceInterface
{
public $passwordLogs;
public $pl_id;
public function __construct(Request $request)
{
}
public function store($admin_id,$password,$created_by, $is_generated = false)
{
$this->passwordLogs = new PasswordLogs;
$this->passwordLogs->admin_id = $admin_id;
$this->passwordLogs->password = md5($password);
$this->passwordLogs->generated_password = $password;
$this->passwordLogs->created_by = $created_by;
$this->passwordLogs->created_dt = date('Y-m-d H:i:s');
if($is_generated)
$this->passwordLogs->is_generated = 1;
$this->passwordLogs->save();
}
public function getByField($data)
{
$this->passwordLogs = new PasswordLogs;
if(count($data))
{
foreach ($data as $field => $value) {
$this->passwordLogs = $this->passwordLogs->where($field,$value);
}
}
return $this->passwordLogs->get();
}
public function getLastLog($admin_id)
{
$this->passwordLogs = PasswordLogs::where('admin_id',$admin_id)
->orderBy('created_dt', 'desc')
->first();
return $this->passwordLogs;
}
}