Compare commits

..

24 Commits
master ... 0.7

Author SHA1 Message Date
Michal Sieciechowicz 73af54b952 fix 2021-09-29 17:19:48 +02:00
Dariusz Jaski 83f328d8ff 0.6 2021-03-17 22:45:55 +01:00
Michal Sieciechowicz f7d8f76a79 Merge remote-tracking branch 'origin/0.4' into 0.5 2021-03-17 13:44:51 +01:00
Michal Sieciechowicz 766c29c5f3 laravel user provider 2021-03-17 13:08:20 +01:00
Dariusz Jaski e14198e262 fix 2021-03-08 22:26:12 +01:00
Dariusz Jaski 1be8bc5511 fix 2021-03-08 20:55:47 +01:00
Dariusz Jaski 37599e8cf6 fix 2021-03-07 11:34:29 +01:00
Dariusz Jaski fbf2aaae07 0.2.3 2021-03-07 11:30:13 +01:00
Dariusz Jaski 1920374639 ns 2021-03-07 11:20:52 +01:00
Dariusz Jaski 1c886fb385 model 2021-03-07 11:17:21 +01:00
Dariusz Jaski b9d1d1601a d 2021-03-07 11:12:43 +01:00
Dariusz Jaski 3f9758c403 fdn 2021-03-07 11:06:39 +01:00
Dariusz Jaski 661406db67 nullsafe 2021-03-07 10:55:23 +01:00
Dariusz Jaski 9c6c34f870 eq 2021-03-07 10:54:11 +01:00
Dariusz Jaski a026facb7c iface 2021-03-07 09:55:06 +01:00
Dariusz Jaski 3c43612503 rename 2021-03-07 09:52:45 +01:00
Dariusz Jaski d32c7a0b92 use 2021-03-07 09:39:13 +01:00
Dariusz Jaski d9da5559c5 NS 2021-03-07 01:53:29 +01:00
Dariusz Jaski afc2b5a261 rename 2021-03-07 01:49:33 +01:00
Dariusz Jaski 54113fffc0 connectors 2021-03-07 01:15:16 +01:00
Michal Sieciechowicz 9204f70e50 0.2.2 2021-03-03 13:41:02 +01:00
Michal Sieciechowicz a3d8bb6131 fixes 2021-03-01 16:25:31 +01:00
Michal Sieciechowicz a3d71c7bc5 fix 2021-03-01 16:22:54 +01:00
Michal Sieciechowicz a3c38a27c7 fixes 2021-03-01 16:06:02 +01:00
2 changed files with 78 additions and 9 deletions

View File

@ -7,7 +7,7 @@ use Fufle\ORM\Database\ConnectionManager;
abstract class Model {
protected static string $primaryKey = 'id';
protected static ?string $table = null;
private static ?IQuery $query = null;
protected static ?IQuery $query = null;
protected static array $fields = [];
@ -15,7 +15,7 @@ abstract class Model {
$array = [];
$fields = static::$fields;
foreach($fields as $field) {
if ($this->{$field} ?? null !== null) {
if (isset($this->{$field})) {
$array[$field] = $this->{$field};
}
}
@ -23,10 +23,7 @@ abstract class Model {
}
protected static function QueryModel() {
if (self::$query === null && self::class !== static::class) {
self::$query = static::SetQueryModel();
}
return self::$query;
return static::SetQueryModel();
}
public static function GetTableName() {
@ -47,18 +44,26 @@ abstract class Model {
}
protected static function Query(string $sql, array|object $params = []) {
return ConnectionManager::Query(
$result = ConnectionManager::Query(
$sql,
$params,
get_called_class());
if (!$result) {
return null;
}
return $result;
}
protected static function QueryAll(string $sql, array|object $params = []) {
return ConnectionManager::QueryAll(
$result = ConnectionManager::QueryAll(
$sql,
$params,
get_called_class());
if (!$result) {
return [];
}
return $result;
}
abstract public static function SetQueryModel(): IQuery;
}

View File

@ -0,0 +1,64 @@
<?php
namespace Fufle\ORM\Providers;
use Fufle\ORM\Model;
use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
class PassportUserProvider implements UserProvider {
/**
* The ORM User Model
*/
private $model;
/**
* Create a new ORM user provider.
*
* @return \Illuminate\Contracts\Auth\Authenticatable|null
* @return void
*/
public function __construct(Model $userModel) {
$this->model = $userModel;
}
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials) {
if (empty($credentials)) {
return;
}
$user = $this->model->findForPassport($credentials['username']);
return $user;
}
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials Request credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, Array $credentials) {
return ($credentials['username'] == $user->getAuthIdentifier() &&
md5($credentials['password']) == $user->getAuthPassword());
}
public function retrieveById($identifier) {
$userClass = get_class($this->model);
return $userClass::FindOrFail($identifier);
}
public function retrieveByToken($identifier, $token) {
}
public function updateRememberToken(Authenticatable $user, $token) {
}
}