Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test-project
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Junaid Rahman pv
test-project
Commits
5bf8bf66
Commit
5bf8bf66
authored
Sep 09, 2016
by
Junaid Rahman pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified business module and website module, added domain creation feature
parent
d29c487c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
17 deletions
+81
-17
_form.php
backend/modules/business/views/business/_form.php
+8
-8
Business.php
common/models/Business.php
+26
-2
Website.php
common/models/Website.php
+34
-2
SiteController.php
frontend/controllers/SiteController.php
+8
-2
index.php
frontend/views/site/index.php
+5
-3
No files found.
backend/modules/business/views/business/_form.php
View file @
5bf8bf66
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
use
yii\widgets\ActiveForm
;
use
common\widgets\PlacePicker\PlacePicker
;
use
common\widgets\PlacePicker\PlacePicker
;
use
trntv\filekit\widget\Upload
;
/* @var $this yii\web\View */
/* @var $this yii\web\View */
/* @var $model common\models\Business */
/* @var $model common\models\Business */
...
@@ -111,14 +112,13 @@ use common\widgets\PlacePicker\PlacePicker;
...
@@ -111,14 +112,13 @@ use common\widgets\PlacePicker\PlacePicker;
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<?=
$form
->
field
(
$model
,
'logo_base_url'
)
->
textInput
([
'maxlength'
=>
true
])
?>
<?=
$form
->
field
(
$model
,
'logo'
)
->
widget
(
Upload
::
className
(),
</div>
[
</div>
'url'
=>
[
'/file-storage/upload'
],
<div
class=
"row"
>
'maxFileSize'
=>
5000000
,
// 5 MiB
<div
class=
"col-md-4"
>
]);
?>
<?=
$form
->
field
(
$model
,
'logo_path'
)
->
textInput
([
'maxlength'
=>
true
])
?>
</div>
</div>
</div>
</div>
...
...
common/models/Business.php
View file @
5bf8bf66
...
@@ -5,6 +5,7 @@ namespace common\models;
...
@@ -5,6 +5,7 @@ namespace common\models;
use
Yii
;
use
Yii
;
use
yii\behaviors\SluggableBehavior
;
use
yii\behaviors\SluggableBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
trntv\filekit\behaviors\UploadBehavior
;
/**
/**
* This is the model class for table "{{%business}}".
* This is the model class for table "{{%business}}".
...
@@ -40,6 +41,11 @@ class Business extends \yii\db\ActiveRecord
...
@@ -40,6 +41,11 @@ class Business extends \yii\db\ActiveRecord
const
STATUS_IN_ACTIVE
=
0
;
const
STATUS_IN_ACTIVE
=
0
;
/**
/**
* @var array
*/
public
$logo
;
/**
* @inheritdoc
* @inheritdoc
*/
*/
public
static
function
tableName
()
public
static
function
tableName
()
...
@@ -63,6 +69,12 @@ class Business extends \yii\db\ActiveRecord
...
@@ -63,6 +69,12 @@ class Business extends \yii\db\ActiveRecord
'class'
=>
TimestampBehavior
::
className
(),
'class'
=>
TimestampBehavior
::
className
(),
'createdAtAttribute'
=>
'created_at'
,
'createdAtAttribute'
=>
'created_at'
,
'updatedAtAttribute'
=>
'updated_at'
'updatedAtAttribute'
=>
'updated_at'
],
[
'class'
=>
UploadBehavior
::
className
(),
'attribute'
=>
'logo'
,
'pathAttribute'
=>
'logo_path'
,
'baseUrlAttribute'
=>
'logo_base_url'
]
]
];
];
}
}
...
@@ -79,8 +91,20 @@ class Business extends \yii\db\ActiveRecord
...
@@ -79,8 +91,20 @@ class Business extends \yii\db\ActiveRecord
[[
'landmark'
],
'string'
,
'max'
=>
500
],
[[
'landmark'
],
'string'
,
'max'
=>
500
],
[[
'contact_no'
],
'string'
,
'max'
=>
150
],
[[
'contact_no'
],
'string'
,
'max'
=>
150
],
[[
'latitude'
,
'longitude'
],
'string'
,
'max'
=>
30
],
[[
'latitude'
,
'longitude'
],
'string'
,
'max'
=>
30
],
[[
'category_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Category
::
className
(),
'targetAttribute'
=>
[
'category_id'
=>
'id'
]],
[
[[
'district_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
District
::
className
(),
'targetAttribute'
=>
[
'district_id'
=>
'id'
]],
[
'category_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
Category
::
className
(),
'targetAttribute'
=>
[
'category_id'
=>
'id'
]
],
[
[
'district_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
District
::
className
(),
'targetAttribute'
=>
[
'district_id'
=>
'id'
]
],
];
];
}
}
...
...
common/models/Website.php
View file @
5bf8bf66
...
@@ -4,7 +4,6 @@ namespace common\models;
...
@@ -4,7 +4,6 @@ namespace common\models;
use
Yii
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
MongoDB\BSON\UTCDatetime
;
/**
/**
* This is the model class for table "{{%website}}".
* This is the model class for table "{{%website}}".
...
@@ -50,7 +49,7 @@ class Website extends \yii\db\ActiveRecord
...
@@ -50,7 +49,7 @@ class Website extends \yii\db\ActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'business_id'
,
'theme_id'
,
'status'
,
'expiry_date'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'business_id'
,
'theme_id'
,
'status'
,
'expiry_date'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'domain_name'
],
'required'
],
[[
'domain_name'
],
'required'
],
[[
'domain_name'
],
'string'
,
'max'
=>
255
],
[[
'domain_name'
],
'string'
,
'max'
=>
255
],
[
[
...
@@ -109,11 +108,44 @@ class Website extends \yii\db\ActiveRecord
...
@@ -109,11 +108,44 @@ class Website extends \yii\db\ActiveRecord
];
];
}
}
public
function
beforeDelete
()
{
if
(
parent
::
beforeDelete
())
// TODO: Change the autogenerated stub
{
$file
=
'C:/Windows/System32/drivers/etc/hosts'
;
$contents
=
file_get_contents
(
$file
);
$contents
=
str_replace
(
$this
->
domain_name
,
''
,
$contents
);
file_put_contents
(
$file
,
$contents
);
return
true
;
}
else
{
return
false
;
}
}
public
function
beforeSave
(
$insert
)
public
function
beforeSave
(
$insert
)
{
{
if
(
parent
::
beforeSave
(
$insert
))
{
if
(
parent
::
beforeSave
(
$insert
))
{
//setting expiry date to 1 year
$expiry_date
=
date
(
'Y-m-d'
,
strtotime
(
'+1 years'
));
$expiry_date
=
date
(
'Y-m-d'
,
strtotime
(
'+1 years'
));
$this
->
expiry_date
=
strtotime
(
$expiry_date
);
$this
->
expiry_date
=
strtotime
(
$expiry_date
);
//writing new domain to host file
$file
=
'C:/Windows/System32/drivers/etc/hosts'
;
$content
=
file_get_contents
(
$file
);
$oldData
=
self
::
findOne
(
$this
->
id
);
if
(
$this
->
isNewRecord
)
{
$domain
=
' '
.
$this
->
domain_name
;
$content
.=
$domain
;
}
else
{
if
(
$oldData
->
domain_name
!=
$this
->
domain_name
)
{
$oldDomain
=
$oldData
->
domain_name
;
$newDomain
=
$this
->
domain_name
;
$content
=
str_replace
(
"
$oldDomain
"
,
"
$newDomain
"
,
$content
);
}
}
file_put_contents
(
$file
,
$content
);
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
frontend/controllers/SiteController.php
View file @
5bf8bf66
<?php
<?php
namespace
frontend\controllers
;
namespace
frontend\controllers
;
use
common\models\Website
;
use
Yii
;
use
Yii
;
use
frontend\models\ContactForm
;
use
frontend\models\ContactForm
;
use
yii\web\Controller
;
use
yii\web\Controller
;
use
yii\httpclient\Client
;
use
yii\httpclient\Client
;
use
yii\db\Query
;
/**
/**
* Site controller
* Site controller
...
@@ -33,14 +35,18 @@ class SiteController extends Controller
...
@@ -33,14 +35,18 @@ class SiteController extends Controller
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$domain
=
$_SERVER
[
'HTTP_HOST'
];
$website
=
Website
::
find
()
->
where
([
'domain_name'
=>
$domain
])
->
one
();
echo
'jhsda'
;
$businessId
=
$website
->
business_id
;
$client
=
new
Client
();
$client
=
new
Client
();
$response
=
$client
->
createRequest
()
$response
=
$client
->
createRequest
()
->
setMethod
(
'get'
)
->
setMethod
(
'get'
)
->
setUrl
(
'http://libromi.com/api/v1/business/view'
)
->
setUrl
(
'http://libromi.com/api/v1/business/view'
)
->
setData
([
'id'
=>
'3997'
])
->
setData
([
'id'
=>
$businessId
])
->
send
();
->
send
();
// echo '<pre>';
// echo '<pre>';
//
var_dump($response)
;
//
echo $businessId
;
// echo '</pre>';
// echo '</pre>';
// exit;
// exit;
$data
=
$response
->
isOk
?
$response
->
data
:
[];
$data
=
$response
->
isOk
?
$response
->
data
:
[];
...
...
frontend/views/site/index.php
View file @
5bf8bf66
<?php
<?php
/* @var $this yii\web\View */
/* @var $this yii\web\View */
/* @var $data array*/
$this
->
title
=
Yii
::
$app
->
name
;
$this
->
title
=
Yii
::
$app
->
name
;
?>
?>
<div
class=
"site-index"
>
<div
class=
"site-index"
>
<?php
<?php
echo
'Name :'
.
$data
[
'name'
];
?>
print_r
(
$data
);
<br>
?>
<?php
echo
'Email :'
.
$data
[
'email'
];
?>
</div>
</div>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment