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
13cf417b
Commit
13cf417b
authored
Sep 09, 2016
by
dianc
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/development' into development
parents
45d0743a
687b4661
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
21 deletions
+79
-21
_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
+6
-6
index.php
frontend/views/site/index.php
+5
-3
No files found.
backend/modules/business/views/business/_form.php
View file @
13cf417b
...
...
@@ -3,6 +3,7 @@
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
use
common\widgets\PlacePicker\PlacePicker
;
use
trntv\filekit\widget\Upload
;
/* @var $this yii\web\View */
/* @var $model common\models\Business */
...
...
@@ -111,14 +112,13 @@ use common\widgets\PlacePicker\PlacePicker;
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<?=
$form
->
field
(
$model
,
'logo_base_url'
)
->
textInput
([
'maxlength'
=>
true
])
?>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<?=
$form
->
field
(
$model
,
'logo_path'
)
->
textInput
([
'maxlength'
=>
true
])
?>
<?=
$form
->
field
(
$model
,
'logo'
)
->
widget
(
Upload
::
className
(),
[
'url'
=>
[
'/file-storage/upload'
],
'maxFileSize'
=>
5000000
,
// 5 MiB
]);
?>
</div>
</div>
...
...
common/models/Business.php
View file @
13cf417b
...
...
@@ -5,6 +5,7 @@ namespace common\models;
use
Yii
;
use
yii\behaviors\SluggableBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
trntv\filekit\behaviors\UploadBehavior
;
/**
* This is the model class for table "{{%business}}".
...
...
@@ -40,6 +41,11 @@ class Business extends \yii\db\ActiveRecord
const
STATUS_IN_ACTIVE
=
0
;
/**
* @var array
*/
public
$logo
;
/**
* @inheritdoc
*/
public
static
function
tableName
()
...
...
@@ -63,6 +69,12 @@ class Business extends \yii\db\ActiveRecord
'class'
=>
TimestampBehavior
::
className
(),
'createdAtAttribute'
=>
'created_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
[[
'landmark'
],
'string'
,
'max'
=>
500
],
[[
'contact_no'
],
'string'
,
'max'
=>
150
],
[[
'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 @
13cf417b
...
...
@@ -4,7 +4,6 @@ namespace common\models;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
MongoDB\BSON\UTCDatetime
;
/**
* This is the model class for table "{{%website}}".
...
...
@@ -50,7 +49,7 @@ class Website extends \yii\db\ActiveRecord
public
function
rules
()
{
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'
],
'string'
,
'max'
=>
255
],
[
...
...
@@ -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
)
{
if
(
parent
::
beforeSave
(
$insert
))
{
//setting expiry date to 1 year
$expiry_date
=
date
(
'Y-m-d'
,
strtotime
(
'+1 years'
));
$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
;
}
else
{
return
false
;
...
...
frontend/controllers/SiteController.php
View file @
13cf417b
<?php
namespace
frontend\controllers
;
use
common\models\Website
;
use
Yii
;
use
frontend\models\ContactForm
;
use
yii\web\Controller
;
use
yii\httpclient\Client
;
use
yii\db\Query
;
/**
* Site controller
...
...
@@ -33,18 +35,16 @@ class SiteController extends Controller
public
function
actionIndex
()
{
$domain
=
$_SERVER
[
'HTTP_HOST'
];
$website
=
Website
::
find
()
->
where
([
'domain_name'
=>
$domain
])
->
one
();
$businessId
=
$website
->
business_id
;
$client
=
new
Client
();
$response
=
$client
->
createRequest
()
->
setMethod
(
'get'
)
->
setUrl
(
'http://libromi.com/api/v1/business/view'
)
->
setData
([
'id'
=>
'3997'
])
->
setData
([
'id'
=>
$businessId
])
->
send
();
// echo '<pre>';
// var_dump($response);
// echo '</pre>';
// exit;
$data
=
$response
->
isOk
?
$response
->
data
:
[];
return
$this
->
render
(
'index'
,
[
'data'
=>
$data
]);
}
...
...
frontend/views/site/index.php
View file @
13cf417b
<?php
/* @var $this yii\web\View */
/* @var $data array*/
$this
->
title
=
Yii
::
$app
->
name
;
?>
<div
class=
"site-index"
>
<?php
print_r
(
$data
);
?>
<?php
echo
'Name :'
.
$data
[
'name'
];
?>
<br>
<?php
echo
'Email :'
.
$data
[
'email'
];
?>
</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