Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Yashwant
/
hdfc
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4a9f4561
authored
2017-11-07 17:03:32 +0530
by
Yashwant
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
relationship tagging data process script
1 parent
59b5c059
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
0 deletions
application/app/Console/Commands/relationship_tag.php
application/app/Console/Kernel.php
application/app/Models/RelationshipCategory.php
application/app/Models/RelationshipService.php
application/app/Models/RelationshipSubCategory.php
application/app/Console/Commands/relationship_tag.php
0 → 100644
View file @
4a9f456
<?php
namespace
App\Console\Commands
;
use
Illuminate\Console\Command
;
use
DB
;
use
App\Models\RelationshipService
;
use
App\Models\RelationshipCategory
;
use
App\Models\RelationshipSubCategory
;
use
Config
;
use
Schema
;
use
PDO
;
use
Illuminate\Database\Schema\Blueprint
;
class
relationship_tag
extends
Command
{
/**
* The console command name.
*
* @var string
*/
protected
$signature
=
'relationship_tag'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'relationship_tag'
;
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$nowts
=
time
();
echo
date
(
'Y-m-d H:i:s'
)
.
"
\n
"
;
$tcol
=
0
;
$fieldsarr
=
array
();
$extrahdrarr
=
array
();
$server_ip
=
env
(
'app_ip'
);
$central_ip
=
env
(
'app_ip'
);
$conn
=
array
(
'driver'
=>
'mysql'
,
'host'
=>
$central_ip
,
'database'
=>
env
(
'DB_DATABASE'
,
'kstych_flexydial'
),
'username'
=>
env
(
'DB_USERNAME'
,
'root'
),
'password'
=>
env
(
'DB_PASSWORD'
,
''
),
'charset'
=>
'utf8'
,
'collation'
=>
'utf8_unicode_ci'
,
'prefix'
=>
''
,
'options'
=>
array
(
PDO
::
ATTR_TIMEOUT
=>
5
,
),
);
Config
::
set
(
"database.connections.conn"
,
$conn
);
if
(
DB
::
connection
(
"conn"
)
->
getDatabaseName
())
{
$relationshipList
=
DB
::
connection
(
"conn"
)
->
select
(
DB
::
raw
(
"SELECT * FROM relationship_tagging"
));
$relationshipData
=
0
;
$newService
=
0
;
$newCategory
=
0
;
$newSubCategory
=
0
;
foreach
(
$relationshipList
as
$list
)
{
$service
=
RelationshipService
::
where
(
'title'
,
'='
,
$list
->
service
)
->
first
();
if
(
count
(
$service
)){
$serviceId
=
$service
->
id
;
}
else
{
$addService
=
RelationshipService
::
create
([
'title'
=>
$list
->
service
]);
$serviceId
=
$addService
->
id
;
$newService
++
;
}
echo
$list
->
service
.
" : "
.
$serviceId
.
" - "
;
$category
=
RelationshipCategory
::
where
(
'service_id'
,
'='
,
$serviceId
)
->
where
(
'title'
,
'='
,
$list
->
category
)
->
first
();
if
(
count
(
$category
)){
$categoryId
=
$category
->
id
;
}
else
{
$addCategory
=
RelationshipCategory
::
create
([
'service_id'
=>
$serviceId
,
'title'
=>
$list
->
category
]);
$categoryId
=
$addCategory
->
id
;
$newCategory
++
;
}
echo
$list
->
category
.
" : "
.
$categoryId
.
" - "
;
$subCategory
=
RelationshipSubCategory
::
where
(
'category_id'
,
'='
,
$categoryId
)
->
where
(
'title'
,
'='
,
$list
->
sub_category
)
->
first
();
if
(
count
(
$subCategory
)){
$subCategoryId
=
$subCategory
->
id
;
}
else
{
$addSubCategory
=
RelationshipSubCategory
::
create
([
'category_id'
=>
$categoryId
,
'title'
=>
$list
->
sub_category
]);
$subCategoryId
=
$addSubCategory
->
id
;
$newSubCategory
++
;
}
echo
$list
->
sub_category
.
" : "
.
$subCategoryId
.
"
\n
"
;
//DB::table('relationship_tagging')->where('id', $list->id)->update(['status'=>'InActive']);
$relationshipData
++
;
}
echo
"Total "
.
$relationshipData
.
" data process and "
.
$newService
.
" service, "
.
$newCategory
.
" category, "
.
$newSubCategory
.
" sub category added
\n
"
;
DB
::
connection
(
"conn"
)
->
disconnect
();
}
}
}
\ No newline at end of file
application/app/Console/Kernel.php
View file @
4a9f456
...
...
@@ -35,6 +35,7 @@ protected $commands = [
'App\Console\Commands\dailyupload_calllog'
,
'App\Console\Commands\dailyupload_questionaire'
,
'App\Console\Commands\relationship_data'
,
'App\Console\Commands\relationship_tag'
,
];
/**
...
...
application/app/Models/RelationshipCategory.php
0 → 100644
View file @
4a9f456
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
RelationshipCategory
extends
Model
{
protected
$table
=
'relationship_category'
;
protected
$fillable
=
[
'service_id'
,
'title'
];
}
\ No newline at end of file
application/app/Models/RelationshipService.php
0 → 100644
View file @
4a9f456
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
RelationshipService
extends
Model
{
protected
$table
=
'relationship_service'
;
protected
$fillable
=
[
'title'
];
}
\ No newline at end of file
application/app/Models/RelationshipSubCategory.php
0 → 100644
View file @
4a9f456
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
RelationshipSubCategory
extends
Model
{
protected
$table
=
'relationship_sub_category'
;
protected
$fillable
=
[
'category_id'
,
'title'
];
}
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment