5 files changed
+37
-20
No files matched your search
@@ -8,10 +8,13 @@
|
|||||||
<a href="https://packagist.org/packages/hekmatinasser/verta"><img src="https://poser.pugx.org/hekmatinasser/verta/license" alt="License"></a>
|
<a href="https://packagist.org/packages/hekmatinasser/verta"><img src="https://poser.pugx.org/hekmatinasser/verta/license" alt="License"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2 align="center"><a href="https://hekmatinasser.github.io/verta">Document</a></h2>
|
<p align="center">
|
||||||
|
<a href="https://hekmatinasser.github.io/verta">English Document</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center">The Verta is package for change solar calendar and gregorian together and provide helper function to use date and time.</p>
|
<p align="center">The Verta is package for change solar calendar and gregorian together and provide helper function to use date and time.</p>
|
||||||
<p align="center">Verta extend class PHP Datetime and Jalali, compatible with Carbon Package.</p>
|
<p align="center">Verta extend class PHP Datetime and Jalali, compatible with Carbon Package.</p>
|
||||||
|
<p align="center">This package has been created by Nasser Hekmati under the license of MIT.</p>
|
||||||
|
|
||||||
|
|
||||||
## Quick view
|
## Quick view
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
"name": "hekmatinasser/verta",
|
"name": "hekmatinasser/verta",
|
||||||
"description": "This Package helps developers to work with Jalali Datetime class for Laravel Framework PHP",
|
"description": "This Package helps developers to work with Jalali Datetime class for Laravel Framework PHP",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"type": "library",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Nasser Hekmati",
|
"name": "Nasser Hekmati",
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
"php": "^8.0",
|
"php": "^8.0",
|
||||||
"illuminate/support": "^8.0|^9.0",
|
"illuminate/support": "^8.0|^9.0",
|
||||||
"illuminate/validation": "^8.0|^9.0",
|
"illuminate/validation": "^8.0|^9.0",
|
||||||
"hekmatinasser/jalali": "^8.0"
|
"hekmatinasser/jalali": "^8.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"orchestra/testbench": "^4.18|^5.20|^6.24|^7.0"
|
"orchestra/testbench": "^4.18|^5.20|^6.24|^7.0"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Hekmatinasser\Verta\Laravel;
|
namespace Hekmatinasser\Verta\Laravel;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Hekmatinasser\Verta\Verta;
|
use Hekmatinasser\Verta\Verta;
|
||||||
|
|
||||||
class JalaliValidator
|
class JalaliValidator
|
||||||
@@ -22,7 +23,7 @@ class JalaliValidator
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Verta::parseFormat($format, $value);
|
Verta::parseFormat($format, $value);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->eq($base);
|
return Verta::parseFormat($format, $value)->eq($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->ne($base);
|
return Verta::parseFormat($format, $value)->ne($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +95,7 @@ class JalaliValidator
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Verta::parseFormat($format, $value);
|
Verta::parseFormat($format, $value);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->eq($base);
|
return Verta::parseFormat($format, $value)->eq($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +145,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->ne($base);
|
return Verta::parseFormat($format, $value)->ne($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +169,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->gt($base);
|
return Verta::parseFormat($format, $value)->gt($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->gte($base);
|
return Verta::parseFormat($format, $value)->gte($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +217,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->gt($base);
|
return Verta::parseFormat($format, $value)->gt($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +241,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->gte($base);
|
return Verta::parseFormat($format, $value)->gte($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +265,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->lt($base);
|
return Verta::parseFormat($format, $value)->lt($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +289,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->lte($base);
|
return Verta::parseFormat($format, $value)->lte($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +313,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->lt($base);
|
return Verta::parseFormat($format, $value)->lt($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,7 +337,7 @@ class JalaliValidator
|
|||||||
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
$base = count($parameters) > 0 ? Verta::parseFormat($format, $parameters[0]) : null;
|
||||||
|
|
||||||
return Verta::parseFormat($format, $value)->lte($base);
|
return Verta::parseFormat($format, $value)->lte($base);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ class VertaServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->loadValidators();
|
$this->loadValidators();
|
||||||
|
|
||||||
|
Carbon::macro('toJalali', function ($timezone = null) {
|
||||||
|
return new Verta($this, $timezone);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,10 +92,6 @@ class VertaServiceProvider extends ServiceProvider
|
|||||||
$this->app->bind('verta', function ($app) {
|
$this->app->bind('verta', function ($app) {
|
||||||
return new Verta();
|
return new Verta();
|
||||||
});
|
});
|
||||||
|
|
||||||
Carbon::macro('toJalali', function ($timezone = null) {
|
|
||||||
return new Verta($this, $timezone);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,20 @@
|
|||||||
|
|
||||||
namespace Hekmatinasser\Verta;
|
namespace Hekmatinasser\Verta;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Hekmatinasser\Jalali\Jalali;
|
use Hekmatinasser\Jalali\Jalali;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class Verta extends Jalali
|
class Verta extends Jalali
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Create a Carbon instance from Verta
|
||||||
|
*
|
||||||
|
* @return Carbon
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function toCarbon(): Carbon
|
||||||
|
{
|
||||||
|
return new Carbon($this->datetime(), $this->timezone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user