- Add status checker + admin secure packages + upgrade enum + add sentry + upgrade to sitemap generator + bump to CRMV2 - Set customer role enum and user role enum - Update customer migration to set roles - phpcbf - faker local to fr - update lang - composer update - bump laravel ui - Redo all user crud - npm bump - Create admin command - rearrange views - redo all auth system - redo customer pro bo
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class Cotationsxml implements Rule
|
|
{
|
|
private $schema_errors = "Le fichier n'est pas conforme au schéma XSD : ";
|
|
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return boolean
|
|
*/
|
|
public function passes($attribute, $value)
|
|
{
|
|
// file is stored, now validate the schema
|
|
$xsd = storage_path('app/cotations/Jeusselin.xsd');
|
|
$domDocument = new \DOMDocument();
|
|
$domDocument->load($value->path());
|
|
// Enable user error handling
|
|
libxml_use_internal_errors(true);
|
|
if (!$domDocument->schemaValidate($xsd)) {
|
|
$errors = libxml_get_errors();
|
|
foreach ($errors as $error) {
|
|
$this->schema_errors .= $error->message;
|
|
}
|
|
libxml_clear_errors();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function message()
|
|
{
|
|
return $this->schema_errors;
|
|
}
|
|
}
|