Commit 25cbe9d8 by Arpit Jain

Read CSV file and update database for locater feeds, run: URL/cron/import

parent 5ffd9c80
......@@ -11,6 +11,9 @@ use App\Page;
use App\City;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
//use App\Exports\UsersExport;
use App\Imports\FeedsImport;
use Maatwebsite\Excel\Facades\Excel;
......@@ -108,4 +111,12 @@ class CronController extends Controller
]);
}
public function import()
{
$file = Storage::path('and-google-in.csv');
$data = Excel::import(new FeedsImport,$file);
echo "Updated Successfully";
die;
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ class SearchController extends Controller
$api_url = config('app.api_list');
$apiLocaterData = $this->call_api_page($api_url, $locality, $state, $city, $location, $ratingOrder, $page);
if ( count($apiLocaterData['data']) < 1 )
return ['status' => 'error', 'data' => 'No data found!'];
......@@ -72,7 +72,6 @@ class SearchController extends Controller
public function index(Request $request)
{
$final = $this->getApiData();
if($final['status'] == 'success'){
$finalData = $final['data']['finalData'];
......
<?php
namespace App\Imports;
use App\LocaterFeed;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class FeedsImport implements ToModel, WithHeadingRow
{
/**
* @param array $row
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function model(array $row)
{
return new LocaterFeed([
'feeds_id' => $row['id'],
'title' => $row['title'],
'description' => htmlentities($row['description']),
'gtin' => $row['gtin'],
'brand' => $row['brand'],
'color' => $row['color'],
'size' => trim($row['size']),
'link' => $row['link'],
'image_link' => $row['image_link'],
'availability' => $row['availability'],
'product_condition' => $row['condition'],
'item_group_id' => $row['item_group_id'],
'google_product_category' => $row['google_product_category'],
'product_type' => $row['product_type'],
'sale_price' => $row['sale_price'],
'price' => $row['price'],
]);
}
}
\ No newline at end of file
<?php
namespace App\Exports;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
class UsersExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return User::all();
}
}
\ No newline at end of file
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Kyslik\ColumnSortable\Sortable;
class LocaterFeed extends Model
{
use Notifiable;
use Sortable;
protected $table = 'locater_feeds';
protected $fillable = ['feeds_id','title','description','gtin','brand','color','size','link','image_link','availability','product_condition','item_group_id','google_product_category','product_type','sale_price','price'];
}
......@@ -35,7 +35,7 @@ Trait Apitraits
public function getAPiKey(){
$file = Storage::disk('public')->exists('key/apikey.dba');
//echo $file; die;
if($file == false){
$api_key = $this->createFileAndPutApiKey();
......@@ -47,8 +47,9 @@ Trait Apitraits
$expieryDate = date('d-m-Y', strtotime($time. ' + 15 days'));
$expieryUpdationDate = date('d-m-Y', strtotime($expieryDate. ' - 1 days'));
$currentDate = date('d-m-Y');
if(strtotime($currentDate) == strtotime($expieryUpdationDate)){
if(strtotime($currentDate) >= strtotime($expieryUpdationDate)){
$file = Storage::disk('public')->exists('key/apikey.dba');
$api_key_url = config('app.api_key_url');
......@@ -105,7 +106,7 @@ Trait Apitraits
public function call_api_page($api_url, $locatorID=null, $state=null, $city=null, $location=null, $ratingOrder=null, $page=1)
{
$apiKey = $this->getAPiKey();
if(!empty($locatorID)){
$locatorID = $locatorID;
}else{
......
......@@ -16,6 +16,7 @@
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.8",
"maatwebsite/excel": "^3.1",
"unisharp/laravel-ckeditor": "^4.7"
},
"require-dev": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1f18c88ad17dd9b340133e3777d7ad74",
"content-hash": "9aa5ff5eb3d0ea007715a55d547c5b93",
"packages": [
{
"name": "dnoegel/php-xdg-base-dir",
......@@ -1125,6 +1125,239 @@
"time": "2019-06-18T20:09:29+00:00"
},
{
"name": "maatwebsite/excel",
"version": "3.1.15",
"source": {
"type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "7d47c7af2ddcf93b4fee4f167e10702e918f69f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/7d47c7af2ddcf93b4fee4f167e10702e918f69f1",
"reference": "7d47c7af2ddcf93b4fee4f167e10702e918f69f1",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*",
"opis/closure": "^3.1",
"php": "^7.0",
"phpoffice/phpspreadsheet": "^1.6"
},
"require-dev": {
"mockery/mockery": "^1.1",
"orchestra/database": "^3.8",
"orchestra/testbench": "^3.8",
"phpunit/phpunit": "^8.0",
"predis/predis": "^1.1"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
}
}
},
"autoload": {
"psr-4": {
"Maatwebsite\\Excel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Patrick Brouwers",
"email": "patrick@maatwebsite.nl"
}
],
"description": "Supercharged Excel exports and imports in Laravel",
"keywords": [
"PHPExcel",
"batch",
"csv",
"excel",
"export",
"import",
"laravel",
"php",
"phpspreadsheet"
],
"time": "2019-07-16T08:40:48+00:00"
},
{
"name": "markbaker/complex",
"version": "1.4.7",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
"reference": "1ea674a8308baf547cbcbd30c5fcd6d301b7c000",
"shasum": ""
},
"require": {
"php": "^5.6.0|^7.0.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"phpcompatibility/php-compatibility": "^8.0",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "2.*",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^4.8.35|^5.4.0",
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "^3.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
},
"files": [
"classes/src/functions/abs.php",
"classes/src/functions/acos.php",
"classes/src/functions/acosh.php",
"classes/src/functions/acot.php",
"classes/src/functions/acoth.php",
"classes/src/functions/acsc.php",
"classes/src/functions/acsch.php",
"classes/src/functions/argument.php",
"classes/src/functions/asec.php",
"classes/src/functions/asech.php",
"classes/src/functions/asin.php",
"classes/src/functions/asinh.php",
"classes/src/functions/atan.php",
"classes/src/functions/atanh.php",
"classes/src/functions/conjugate.php",
"classes/src/functions/cos.php",
"classes/src/functions/cosh.php",
"classes/src/functions/cot.php",
"classes/src/functions/coth.php",
"classes/src/functions/csc.php",
"classes/src/functions/csch.php",
"classes/src/functions/exp.php",
"classes/src/functions/inverse.php",
"classes/src/functions/ln.php",
"classes/src/functions/log2.php",
"classes/src/functions/log10.php",
"classes/src/functions/negative.php",
"classes/src/functions/pow.php",
"classes/src/functions/rho.php",
"classes/src/functions/sec.php",
"classes/src/functions/sech.php",
"classes/src/functions/sin.php",
"classes/src/functions/sinh.php",
"classes/src/functions/sqrt.php",
"classes/src/functions/tan.php",
"classes/src/functions/tanh.php",
"classes/src/functions/theta.php",
"classes/src/operations/add.php",
"classes/src/operations/subtract.php",
"classes/src/operations/multiply.php",
"classes/src/operations/divideby.php",
"classes/src/operations/divideinto.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"time": "2018-10-13T23:28:42+00:00"
},
{
"name": "markbaker/matrix",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "6ea97472b5baf12119b4f31f802835b820dd6d64"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/6ea97472b5baf12119b4f31f802835b820dd6d64",
"reference": "6ea97472b5baf12119b4f31f802835b820dd6d64",
"shasum": ""
},
"require": {
"php": "^5.6.0|^7.0.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"phpcompatibility/php-compatibility": "^8.0",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "2.*",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^4.8.35|^5.4.0",
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "^3.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
},
"files": [
"classes/src/functions/adjoint.php",
"classes/src/functions/antidiagonal.php",
"classes/src/functions/cofactors.php",
"classes/src/functions/determinant.php",
"classes/src/functions/diagonal.php",
"classes/src/functions/identity.php",
"classes/src/functions/inverse.php",
"classes/src/functions/minors.php",
"classes/src/functions/trace.php",
"classes/src/functions/transpose.php",
"classes/src/operations/add.php",
"classes/src/operations/directsum.php",
"classes/src/operations/subtract.php",
"classes/src/operations/multiply.php",
"classes/src/operations/divideby.php",
"classes/src/operations/divideinto.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"time": "2018-11-04T22:12:12+00:00"
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"source": {
......@@ -1420,6 +1653,100 @@
"time": "2018-07-02T15:55:56+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "0c1346a1956347590b7db09533966307d20cb7cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/0c1346a1956347590b7db09533966307d20cb7cc",
"reference": "0c1346a1956347590b7db09533966307d20cb7cc",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"markbaker/complex": "^1.4",
"markbaker/matrix": "^1.1",
"php": "^5.6|^7.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"doctrine/instantiator": "^1.0.0",
"dompdf/dompdf": "^0.8.0",
"friendsofphp/php-cs-fixer": "@stable",
"jpgraph/jpgraph": "^4.0",
"mpdf/mpdf": "^7.0.0",
"phpcompatibility/php-compatibility": "^8.0",
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.3",
"tecnickcom/tcpdf": "^6.2"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1-or-later"
],
"authors": [
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
},
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"time": "2019-07-08T21:21:25+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.5.0",
"source": {
......
......@@ -170,6 +170,9 @@ return [
Illuminate\View\ViewServiceProvider::class,
JeroenNoten\LaravelAdminLte\ServiceProvider::class,
Kyslik\ColumnSortable\ColumnSortableServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
/*
* Package Service Providers...
......@@ -239,6 +242,7 @@ return [
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\FormFacade::class,
'Apihelpers' => App\Helpers\Apihelpers::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
],
......
......@@ -26,6 +26,8 @@ Route::post('getCityValue', 'SearchController@getCityValue')->name('getCityValue
Route::get('cron/getLocaterListData', 'CronController@getLocaterListData')->name('getLocaterListData');
Route::get('cron/getState', 'CronController@getState')->name('getState');
Route::get('cron/getCity', 'CronController@getCity')->name('getCity');
Route::get('cron/import', 'CronController@import')->name('import');
Route::get('404',['as'=>'404','uses'=>'ErrorHandlerController@errorCode404']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment