Primo Committ

This commit is contained in:
paoloar77
2024-05-07 12:17:25 +02:00
commit e73d0e5113
7204 changed files with 884387 additions and 0 deletions

81
app/Article.php Normal file
View File

@@ -0,0 +1,81 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
protected $table = 'T_WEB_Articoli';
/*
public function authors()
{
return $this->hasMany(Author::class);
}
*/
public function getAuthorsAttribute()
{
$authorId = $this->getRawOriginal('ListaAutori');
$ids = explode(",",$authorId);
$autori = [];
foreach ($ids as $id)
{
$autore = Author::where('IdAutore',$id)->orderBy('DataOra', 'desc')->first();
if($autore){
//$autori[] = ($autore->Nome != '' ? trim($autore->Nome) . " " : '') . trim($autore->Cognome);
$autori[] = trim($autore->Nome) . "," . trim($autore->Cognome);
}
}
return $autori;
}
public function getStockAttribute()
{
$qtas = Stock::where('Codice', $this->IdArticolo)->orderBy('DataOra', 'desc');
if($qtas->count() > 0 ){
$qta = $qtas->first();
$disponibilita = $qta->QtaDisponibile;
} else {
$disponibilita = 0;
}
return $disponibilita;
}
public function getStatoprodottoAttribute()
{
$status = Statusproduct::where('IdStatoProdotto', $this->IdStatoProdotto)->orderBy('DataOra', 'desc')->first();
return $status->Descrizione;
}
public function getEditoreAttribute()
{
if($this->IdMarchioEditoriale > 0){
$editore = Publisher::where('IdMarchioEditoriale', $this->IdMarchioEditoriale)->orderBy('DataOra', 'desc')->first();
return $editore->Descrizione;
}
else{
return null;
}
}
public function getArgomentoAttribute()
{
$argomenti = Category::where('IdArgomento', $this->ListaArgomenti)->orderBy('DataOra', 'desc');
if($argomenti->count() > 0){
$argomento = $argomenti->first();
$descrizione = $argomento->Descrizione;
} else {
$descrizione = "Nessuna categoria";
}
return $descrizione;
}
public function nimaia()
{
return $this->hasOne('App\Artnim', 'id_gm', 'IdArticolo' );
}
}

14
app/Artnim.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Artnim extends Model
{
protected $connection = 'mysql';
protected $table = 'tblProdotti';
}

10
app/Author.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Author extends Model
{
protected $table = 'T_WEB_Autori';
}

11
app/Authornimaia.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Authornimaia extends Model
{
protected $connection = 'mysql';
protected $table = 'tblAutoriSito';
}

10
app/Category.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
protected $table = 'T_WEB_Argomenti';
}

17
app/Clientegm.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Clientegm extends Model
{
protected $primaryKey = null;
public $incrementing = false;
//protected $connection = 'mysql_test';
protected $connection = 'sqlsrv_test';
protected $table = 'T_WOO_Clienti';
public $timestamps = false;
}

15
app/Clientegmdest.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Clientegmdest extends Model
{
//protected $connection = 'mysql_test';
protected $connection = 'sqlsrv_test';
protected $table = 'T_WOO_Destinazioni';
public $timestamps = false;
}

View File

@@ -0,0 +1,76 @@
<?php
namespace App\Console\Commands;
use App\Order as AppOrder;
use Codexshaper\WooCommerce\Facades\Order;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
class OrderUpdateGm extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'order:gmupdate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Aggiornamenti ordini da GM';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$all_orderswoo = new Collection();
$page = 1;
do{
$orderswoo = Order::all($options = ['per_page' => 100, 'page' => $page,'status'=> ["pending","processing","on-hold"]]);
$all_orderswoo = $all_orderswoo->merge($orderswoo);
$page++;
} while($orderswoo->count() > 0);
foreach($all_orderswoo as $orderwoo ){
$ordergm = AppOrder::where('IdInternet', $orderwoo->id)->latest('DataOra')->first();
if($ordergm){
if($orderwoo->status == 'processing'){
if($ordergm->EnabledWoo == 1){
$data = [
'status' => 'completed',
];
$orderwooupdate = Order::update($orderwoo->id,$data);
}
}
elseif ($orderwoo->status == 'on-hold'){
if($ordergm->FlagSospeso == 0) {
$data = [
'status' => 'processing',
];
$orderwooupdate = Order::update($orderwoo->id,$data);
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Codexshaper\WooCommerce\Facades\Product;
use Illuminate\Console\Command;
use App\Setting;
use App\Article;
use App\Stock;
use Codexshaper\WooCommerce\Models\Product as ModelsProduct;
use Codexshaper\WooCommerce\Facades\Variation;
use Codexshaper\WooCommerce\Facades\Category;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;
class ProductUpdateQta extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'product:updateqta';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Aggiorna qta prodotti da GM';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
set_time_limit(0);
ini_set("memory_limit", "512M");
$ora_update = Carbon::now();
$settingora = Setting::where('key','update_products_qta')->first();
$fromtime = str_replace('-','',$settingora->value);
$loginizio = 'Inizio da '.$ora_update."\n";
/* $stocks = Stock::join(DB::raw('(SELECT Codice, MAX(DataOra) as data1 from T_WEB_Disponibile GROUP BY Codice ) b'), function($join)
{
$join->on('T_WEB_Disponibile.Codice', '=', 'b.Codice')
->on('T_WEB_Disponibile.DataOra', '=', 'b.data1');
} )
->where('data1','>=',$fromtime)
->orderBy('DataOra')
->get();
*/
$stocks = Stock::select('Codice', 'QtaDisponibile', DB::raw('MAX(DataOra) as data_recente'))
->where('DataOra', '>=' , $fromtime)
->groupBy('Codice','QtaDisponibile')
->get();
$nrprodotti = $stocks->count();
foreach($stocks as $stock){
try {
$productsku = Product::where('sku' , $stock->Codice)->first();
if($productsku->count() > 0)
{
$data1 = [
'stock_quantity' => $stock->QtaDisponibile,
];
$idprodotto = $productsku['parent_id'];
if($idprodotto > 0){
$variation = Variation::update($idprodotto,$productsku['id'], $data1);
} else {
Product::update($productsku['id'], $data1);
}
}
} catch (\Exception $e) {
//code error
}
}
$ora_fine = Carbon::now();
$lognrprodotti = 'Prodotti qta aggiornati '.$nrprodotti."\n";
$logfine = 'Terminato il '.$ora_fine."\n";
$settingora->value = $ora_update;
$settingora->save();
Log::channel('updateproductsqta')->notice($loginizio . $lognrprodotti . $logfine);
}
}

View File

@@ -0,0 +1,293 @@
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Codexshaper\WooCommerce\Facades\Product;
use Illuminate\Console\Command;
use App\Setting;
use App\Article;
use Codexshaper\WooCommerce\Models\Product as ModelsProduct;
use Codexshaper\WooCommerce\Facades\Variation;
use Codexshaper\WooCommerce\Facades\Category;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;
class ProductUpdateUsedGm extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'product:used:gmupdate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Aggiorna prodotti usati da GM';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
set_time_limit(0);
ini_set("memory_limit", "512M");
$ora_update = Carbon::now();
$settingora = Setting::where('key','update_products_used')->first();
$fromtime = str_replace('-','',$settingora->value);
$articles = Article::join(DB::raw('(SELECT IdArticolo, MAX(DataOra) AS data FROM T_WEB_Articoli GROUP BY IdArticolo) b'), function($join)
{
$join->on('T_WEB_Articoli.IdArticolo', '=', 'b.IdArticolo')
->on('T_WEB_Articoli.DataOra', '=', 'b.data');
})
->leftJoin(DB::raw('(SELECT e.IdStatoProdotto, e.Descrizione as DescrizioneStatoProdotto FROM T_WEB_StatiProdotto e JOIN (SELECT IdStatoProdotto, MAX(DataOra) as data1 from T_WEB_StatiProdotto GROUP BY IdStatoProdotto) c ON e.IdStatoProdotto = c.IdStatoProdotto AND e.DataOra = c.data1 ) f'), function($join) {
$join->on('T_WEB_Articoli.IdStatoProdotto', '=', 'f.IdStatoProdotto');
})
->leftJoin(DB::raw('(SELECT g.IdTipologia, g.Descrizione as DescrizioneTipologia FROM T_WEB_Tipologie g JOIN (SELECT IdTipologia, MAX(DataOra) as data1 from T_WEB_Tipologie GROUP BY IdTipologia) h ON g.IdTipologia = h.IdTipologia AND g.DataOra = h.data1 ) i'), function($join) {
$join->on('T_WEB_Articoli.IdTipologia', '=', 'i.IdTipologia');
})
->leftJoin(DB::raw('(SELECT l.IdTipoFormato, l.Descrizione as DescrizioneFormato FROM T_WEB_TipiFormato l JOIN (SELECT IdTipoFormato, MAX(DataOra) as data1 from T_WEB_TipiFormato GROUP BY IdTipoFormato) m ON l.IdTipoFormato = m.IdTipoFormato AND l.DataOra = m.data1 ) n'), function($join) {
$join->on('T_WEB_Articoli.IdTipoFormato', '=', 'n.IdTipoFormato');
})
/*
->leftJoin(DB::raw('(SELECT o.Codice, o.QtaDisponibile FROM T_WEB_Disponibile o JOIN (SELECT Codice, MAX(DataOra) as data1 from T_WEB_Disponibile GROUP BY Codice) p ON o.Codice = p.Codice AND o.DataOra = p.data1 ) q'), function($join) {
$join->on('T_WEB_Articoli.IdArticolo', '=', 'q.Codice');
})
*/
//->groupBy('T_WEB_Articoli.IdArticolo')
->where('data','>=',$fromtime)
->where('EAN13','LIKE','usato%')
//->where(function($query){
// $query->where('DescrizioneStatoProdotto','Usato')
//->orWhere('DescrizioneStatoProdotto','In Commercio')
//->orWhere('DescrizioneStatoProdotto','Remainder');
//})
//->where(DB::raw('CONVERT(INT, QtaDisponibile)'),'>',0)
//->where('DescrizioneFormato','brossura')
->where('DescrizioneTipologia','Libri')
->orderBy('data')
//->take(5)
//->orderBy('ListaAutori')
->get();
Log::channel('updateproductsused')->notice('Inizio da '.$settingora->value."\n");
$loginizio = 'Inizio da '.$settingora->value."\n";
$logfine = 'Fino a '.$ora_update."\n";
$log = 'PRODOTTI USATI INSERITI'."\n";
$log1 = 'EVENTUALI PRODOTTI USATI NON INSERITI'."\n";
$log2 = 'PRODOTTI USATI AGGIORNATI' . "\n";
$log3 = 'PRODOTTI USATI NON INSERITI PER PROBLEMI SERVER' . "\n";
foreach($articles as $article)
{ try {
/*
$settingdata = Setting::where('key','data_product_used')->first();
$settingdata->value = $article->data;
$settingdata->save();
*/
$productsku = Product::where('sku' , $article->IdArticolo)->first();
if($productsku->count() == 0)
{
$titolo = null;
$formato = null;
$titolo = $article->Titolo;
$titolo = rtrim($titolo);
$titolo = rtrim(str_ireplace('USATO','',$titolo));
$titolo = rtrim($titolo);
$page = 1;
$all_products = new Collection();
do{
$products = Product::all($options = ['per_page' => 100, 'page' => $page,'search' => $titolo]);
$all_products = $all_products->merge($products);
$page++;
} while ($products->count() > 0);
foreach ($all_products as $product) {
$variations = Variation::all($product->id);
$target_usato = substr($article->Ean13, strlen('USATO'));
foreach ($variations as $variation) {
foreach ($variation->meta_data as $meta_data) {
if ($meta_data->key === 'ISBN') {
// Estrai gli ultimi caratteri dell'ISBN
$isbn_value = substr($meta_data->value, -strlen($target_usato));
//dd($isbn_value);
// Confronta gli ultimi caratteri con il valore desiderato
if ($isbn_value === $target_usato) {
$meta_data->value;
$data1 = [
'regular_price' => $article->PrezzoIvato,
'sku' => $article->IdArticolo,
'sale_price' => $article->PrezzoIvatoScontatoCampagna,
'date_on_sale_from' => $article->DataInizioCampagna,
'date_on_sale_to' => $article->DataFineCampagna,
'manage_stock' => true,
'stock_quantity' => $article->stock,
'purchasable' => false,
'attributes' => [
[
//'id' => 1,
'id' => 6,
'option' => 'Usato'
]
],
'meta_data' => [
[
'key' => 'ISBN',
'value' => $article->Ean13
],
[
'key' => 'misure',
'value' => $article->Misure
],
[
'key' => 'formato',
'value' => $article->DescrizioneFormato
],
[
'key' => 'pagine',
'value' => $article->Pagine
],
[
'key' => 'edizione',
'value' => $article->Edizione
],
[
'key' => 'ristampa',
'value' => $article->Ristampa
],
]
];
$old_attributes = $product->attributes;
$attributes = [];
foreach($old_attributes as $old_attribute)
{
if($old_attribute->id <> 6)
{
$attributes[] = [
'id' => $old_attribute->id,
'variation' => $old_attribute->variation,
'visible' => $old_attribute->visible,
'options' => $old_attribute->options
];
}
}
$attributes[] = [
//'id' => 1,
'id' => 6,
'position' => 0,
'visible' => true,
'variation' => true,
'options' => [
'Nuovo',
'Usato',
'PDF',
'Epub',
'Mobi',
'DVD',
'Streaming',
'Download'
]
];
//dd($attributes);
$data = [
'attributes' => $attributes
];
Product::update($product->id, $data);
$variation = Variation::create($product->id, $data1);
$log .= $article->Titolo . ' - ' . $article->Ean13 . " - " . $variation['permalink']."\n";
break;
}
}
}
}
}
} else {
$data1 = [
'regular_price' => $article->PrezzoIvato,
'sale_price' => $article->PrezzoIvatoScontatoCampagna,
'date_on_sale_from' => $article->DataInizioCampagna,
'date_on_sale_to' => $article->DataFineCampagna,
'stock_quantity' => $article->stock,
];
$idprodotto = $productsku['parent_id'];
//if($idprodotto > 0){
$variation = Variation::update($idprodotto,$productsku['id'], $data1);
//echo "Modificato " . $article->Titolo ."<br>";
$log2 .= $article->Titolo . ' - ' . $article->Ean13 . " - Articolo aggiornato - " . $variation['permalink']."\n";
//}
}
} catch (\Exception $e) {
//$log3 .= $article->IdArticolo . ' - '. $article->Titolo ."\n" ;
}
}
$settingora->value = $ora_update;
$settingora->save();
Log::channel('updateproductsused')->notice($log . $log2 . $log1 . $log3);
Log::channel('updateproductsused')->notice('Fino a '.$ora_update."\n");
Mail::raw($loginizio. $log . $log2 . $log1 . $log3 . $logfine, function ($message) {
$message->to("fioredellavitamacro@gmail.com");
//$message->bcc('luca@pecos.it');
$message->subject("Inserimento nuovi prodotti usati");
});
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use App\Order as AppOrder;
use Codexshaper\WooCommerce\Facades\Order;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
class Test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Test';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
Log::channel('updateproducts')->notice('Prova test scrittura'."\n");
}
}

48
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('backup:clean')->daily()->at('02:00');
$schedule->command('backup:run')->daily()->at('07:00');
$schedule->command('order:gmupdate')->everyTenMinutes();
$schedule->command('product:gmupdate')->daily()->at('02:00');
$schedule->command('product:used:gmupdate')->daily()->at('04:30');
//$schedule->command('product:updateqta')->hourly()->between('8:00', '00:00')->withoutOverlapping();
$schedule->command('product:updateqta')->everyFiveMinutes()->between('8:00', '00:00')->withoutOverlapping();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Throwable
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}

17
app/Gm_product.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gm_product extends Model
{
protected $connection = 'mysql_appoggio';
//protected $connection = 'sqlsrv_test';
public $timestamps = false;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

67
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'http://macro.test/*',
'ordercreate*',
'updatecreate*'
];
}

15
app/Newproduct.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Newproduct extends Model
{
protected $connection = 'mysql_test';
//protected $connection = 'sqlsrv_test';
protected $table = 'articles';
//public $timestamps = false;
}

15
app/Order.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
//protected $connection = 'mysql_test';
protected $connection = 'sqlsrv_test';
protected $table = 'T_WOO_TestateOrdini';
public $timestamps = false;
}

16
app/Orderdetail.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Orderdetail extends Model
{
//protected $connection = 'mysql_test';
protected $connection = 'sqlsrv_test';
protected $table = 'T_WOO_Ordini';
public $timestamps = false;
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

12
app/Publisher.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Publisher extends Model
{
protected $table = 'T_WEB_MarchiEditoriali';
}

17
app/Setting.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
protected $connection = 'mysql_appoggio';
//protected $connection = 'sqlsrv_test';
// public $timestamps = false;
}

12
app/Statusproduct.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Statusproduct extends Model
{
protected $table = 'T_WEB_StatiProdotto';
}

13
app/Stock.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Stock extends Model
{
protected $table = 'T_WEB_Disponibile';
}

39
app/User.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}