Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
norka
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
Ann
norka
Commits
141e09ca
You need to sign in or sign up before continuing.
Commit
141e09ca
authored
Jul 23, 2017
by
Ann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Controllers
parent
f7f4a577
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
319 additions
and
7 deletions
+319
-7
app/Http/Controllers/NewsController.php
+54
-0
app/Http/Controllers/NotificationController.php
+3
-2
app/Http/Controllers/QueryReplyController.php
+41
-1
app/Http/Controllers/QueryTypeController.php
+10
-1
app/Http/Controllers/RelationController.php
+10
-1
app/News.php
+21
-1
app/OverseasAddress.php
+2
-0
app/Relation.php
+8
-1
app/Users.php
+8
-0
database/migrations/2017_07_20_045405_add_name_and_type_to_downloads_table.php
+31
-0
database/migrations/2017_07_20_090623_add_name_and_type_to_scheme_table.php
+31
-0
database/migrations/2017_07_20_115152_create_state_table.php
+35
-0
database/migrations/2017_07_20_115220_create_district_table.php
+35
-0
database/migrations/2017_07_21_080908_add_query_type_to_query_table.php
+30
-0
No files found.
app/Http/Controllers/NewsController.php
View file @
141e09ca
...
@@ -4,9 +4,14 @@ namespace App\Http\Controllers;
...
@@ -4,9 +4,14 @@ namespace App\Http\Controllers;
use
App\News
;
use
App\News
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Validator
;
class
NewsController
extends
Controller
class
NewsController
extends
Controller
{
{
public
function
add
()
{
return
view
(
"news_add"
);
}
public
function
index
()
public
function
index
()
{
{
$news
=
News
::
all
();
$news
=
News
::
all
();
...
@@ -16,4 +21,53 @@ class NewsController extends Controller
...
@@ -16,4 +21,53 @@ class NewsController extends Controller
return
response
(
$data
,
200
);
return
response
(
$data
,
200
);
}
}
public
function
show
()
{
$news
=
News
::
all
();
$data
[
'news'
]
=
$news
;
return
view
(
"news_list"
,
compact
(
'news'
));
}
public
function
store
(
Request
$request
)
{
$input
=
$request
->
all
();
$rules
=
[
'notification_type_id'
=>
'required'
,
'title'
=>
'required'
,
'description'
=>
'required'
,
'news_date'
=>
'required'
,
];
$messages
=
[
'notification_type_id.required'
=>
'Notification type required'
,
'title.required'
=>
'Title required'
,
'description.required'
=>
'Description required'
,
'news_date.required'
=>
'News date required'
];
$validator
=
Validator
::
make
(
$input
,
$rules
,
$messages
);
if
(
$validator
->
passes
())
{
$news
=
new
News
();
$news
->
notification_type_id
=
$input
[
'notification_type_id'
];
$news
->
title
=
$input
[
'title'
];
$news
->
description
=
$input
[
'description'
];
$news
->
news_date
=
date
(
"Y-m-d h:i:s"
,
strtotime
(
$request
->
news_date
));
$news
->
photo_url
=
$news
::
creatNew
(
$input
[
'news_photo'
],
800
,
''
);
$news
->
save
();
$data
[
'status'
]
=
1
;
$data
[
'news_id'
]
=
$news
->
id
;
$data
[
'message'
]
=
"News added successfully"
;
return
response
(
$data
,
200
);
}
else
{
$data
[
'message'
]
=
$validator
->
errors
(
0
);
$data
[
'status'
]
=
0
;
return
response
(
$data
,
400
);
}
}
}
}
app/Http/Controllers/NotificationController.php
View file @
141e09ca
...
@@ -15,7 +15,7 @@ class NotificationController extends Controller
...
@@ -15,7 +15,7 @@ class NotificationController extends Controller
$userid
=
$request
->
userid
;
$userid
=
$request
->
userid
;
if
(
$request
->
id
==
null
)
{
if
(
$request
->
id
==
null
)
{
$district
=
NativeAddress
::
where
(
'user_id'
,
'='
,
$userid
)
->
pluck
(
'district'
);
$district
=
NativeAddress
::
where
(
'user_id'
,
'='
,
$userid
)
->
pluck
(
'district'
);
$notification
=
Notification
::
where
(
'district'
,
'='
,
$district
[
0
]
)
->
take
(
50
)
->
get
();
$notification
=
Notification
::
where
(
'district'
,
'='
,
strval
(
$district
[
0
])
)
->
take
(
50
)
->
get
();
$arr
=
[];
$arr
=
[];
$d
=
[];
$d
=
[];
...
@@ -27,7 +27,8 @@ class NotificationController extends Controller
...
@@ -27,7 +27,8 @@ class NotificationController extends Controller
}
else
{
}
else
{
$arr
[]
=
$not
->
notification_date
;
$arr
[]
=
$not
->
notification_date
;
$d
[
$key
][
'date'
]
=
$not
->
notification_date
;
$d
[
$key
][
'date'
]
=
$not
->
notification_date
;
$d
[
$key
][
'notification'
]
=
Notification
::
where
(
'notification_date'
,
$not
->
notification_date
)
->
get
();
$d
[
$key
][
'notification'
]
=
Notification
::
where
(
'notification_date'
,
$not
->
notification_date
)
->
where
(
'district'
,
'='
,
strval
(
$district
[
0
]))
->
get
();
}
}
}
}
...
...
app/Http/Controllers/QueryReplyController.php
View file @
141e09ca
...
@@ -2,9 +2,49 @@
...
@@ -2,9 +2,49 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\query
;
use
App\query_reply
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
class
QueryReplyController
extends
Controller
class
QueryReplyController
extends
Controller
{
{
//
public
function
index
(
$id
)
{
$query_reply
=
query_reply
::
where
(
'query_id'
,
'='
,
$id
)
->
get
();
if
(
$query_reply
)
{
$data
[
'query_reply'
]
=
$query_reply
;
$data
[
'status'
]
=
1
;
$data
[
'message'
]
=
"Query replies retrieved successfully"
;
return
response
(
$data
,
200
);
}
else
{
$data
[
'status'
]
=
0
;
$data
[
'message'
]
=
"Query reply retrieval failed"
;
return
response
(
$data
,
400
);
}
}
public
function
store
(
Request
$request
)
{
$input
=
$request
->
all
();
$validator
=
\Validator
::
make
(
$input
,
[
'query_id'
=>
'required|integer'
,
'query_reply'
=>
'required|string'
,
]);
if
(
$validator
->
passes
())
{
$query_reply
=
new
query_reply
();
$query_reply
->
query_id
=
$request
->
input
(
'query_id'
);
$query_reply
->
query_reply
=
$request
->
input
(
'query_reply'
);
$query_reply
->
replied_by
=
"0"
;
$query_reply
->
save
();
$toUpdate
=
array
(
'reply_status'
=>
1
);
$result
=
query
::
where
(
'id'
,
$query_reply
->
query_id
)
->
update
(
$toUpdate
);
$data
[
'status'
]
=
1
;
$data
[
'message'
]
=
'Query replied successfully'
;
$data
[
'id'
]
=
$query_reply
->
id
;
return
response
(
$data
,
200
);
}
else
{
$data
[
'message'
]
=
$validator
->
errors
()
->
all
();
$data
[
'status'
]
=
0
;
return
response
(
$data
,
400
);
}
}
}
}
app/Http/Controllers/QueryTypeController.php
View file @
141e09ca
...
@@ -2,9 +2,18 @@
...
@@ -2,9 +2,18 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\query_type
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
class
QueryTypeController
extends
Controller
class
QueryTypeController
extends
Controller
{
{
//
public
function
index
()
{
$query_type
=
query_type
::
all
();
$data
[
'query_type'
]
=
$query_type
;
$data
[
'status'
]
=
1
;
$data
[
'message'
]
=
"Query type retrieved successfully"
;
return
response
(
$data
,
200
);
}
}
}
app/Http/Controllers/RelationController.php
View file @
141e09ca
...
@@ -2,9 +2,18 @@
...
@@ -2,9 +2,18 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Relation
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
class
RelationController
extends
Controller
class
RelationController
extends
Controller
{
{
//
public
function
index
()
{
$relation
=
Relation
::
all
();
$data
[
'relation'
]
=
$relation
;
$data
[
'status'
]
=
1
;
$data
[
'message'
]
=
"Relation retrieved successfully"
;
return
response
(
$data
,
200
);
}
}
}
app/News.php
View file @
141e09ca
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
App
;
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Intervention\Image\Image
;
class
News
extends
Model
class
News
extends
Model
{
{
...
@@ -12,7 +14,6 @@ class News extends Model
...
@@ -12,7 +14,6 @@ class News extends Model
'notification_type_id'
,
'notification_type_id'
,
'title'
,
'title'
,
'description'
,
'description'
,
'notification_date'
,
'news_date'
,
'news_date'
,
'news_time'
,
'news_time'
,
'photo_url'
,
'photo_url'
,
...
@@ -20,4 +21,23 @@ class News extends Model
...
@@ -20,4 +21,23 @@ class News extends Model
'created_at'
,
'created_at'
,
'updated_at'
'updated_at'
];
];
public
static
$path
=
'/news/'
;
public
static
function
creatNew
(
$uploadedFile
,
$width
,
$type
=
'jpg'
)
{
$image
=
\Intervention\Image\Facades\Image
::
make
(
$uploadedFile
);
if
(
$type
==
'.png'
)
{
$image
->
encode
(
'png'
);
}
$fileName
=
filehelper
::
getRandomName
(
$type
);
$path
=
self
::
$path
.
$fileName
;
$image
->
resize
(
$width
,
null
,
function
(
$constraint
)
{
$constraint
->
aspectRatio
();
});
$image
->
save
(
public_path
()
.
'/uploads'
.
$path
);
return
$path
;
}
}
}
app/OverseasAddress.php
View file @
141e09ca
...
@@ -23,4 +23,6 @@ class OverseasAddress extends Model
...
@@ -23,4 +23,6 @@ class OverseasAddress extends Model
'created_at'
,
'created_at'
,
'updated_at'
'updated_at'
];
];
}
}
app/Relation.php
View file @
141e09ca
...
@@ -6,5 +6,12 @@ use Illuminate\Database\Eloquent\Model;
...
@@ -6,5 +6,12 @@ use Illuminate\Database\Eloquent\Model;
class
Relation
extends
Model
class
Relation
extends
Model
{
{
//
protected
$table
=
'relation'
;
protected
$fillable
=
[
'relation'
,
'status'
,
'created_at'
,
'updated_at'
];
}
}
app/Users.php
View file @
141e09ca
...
@@ -42,4 +42,12 @@ class Users extends Model
...
@@ -42,4 +42,12 @@ class Users extends Model
{
{
return
$this
->
belongsTo
(
'App\UserType'
,
'user_type_id'
);
return
$this
->
belongsTo
(
'App\UserType'
,
'user_type_id'
);
}
}
public
function
NativeAddress
()
{
return
$this
->
belongsTo
(
'App\NativeAddress'
,
'user_id'
);
}
public
function
OverseasAddress
()
{
return
$this
->
belongsTo
(
'App\OverseasAddress'
,
'user_id'
);
}
}
}
database/migrations/2017_07_20_045405_add_name_and_type_to_downloads_table.php
0 → 100644
View file @
141e09ca
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
AddNameAndTypeToDownloadsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'downloads'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'filename'
);
$table
->
string
(
'filetype'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'downloads'
);
}
}
database/migrations/2017_07_20_090623_add_name_and_type_to_scheme_table.php
0 → 100644
View file @
141e09ca
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
AddNameAndTypeToSchemeTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'scheme'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'filename'
);
$table
->
string
(
'filetype'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'scheme'
);
}
}
database/migrations/2017_07_20_115152_create_state_table.php
0 → 100644
View file @
141e09ca
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
CreateStateTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'state'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'name'
);
$table
->
bigInteger
(
'country_id'
);
$table
->
tinyInteger
(
'status'
)
->
default
(
'0'
);
$table
->
rememberToken
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'state'
);
}
}
database/migrations/2017_07_20_115220_create_district_table.php
0 → 100644
View file @
141e09ca
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
CreateDistrictTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'district'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'name'
);
$table
->
bigInteger
(
'state_id'
);
$table
->
tinyInteger
(
'status'
)
->
default
(
'0'
);
$table
->
rememberToken
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
//
}
}
database/migrations/2017_07_21_080908_add_query_type_to_query_table.php
0 → 100644
View file @
141e09ca
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
AddQueryTypeToQueryTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'query'
,
function
(
Blueprint
$table
)
{
$table
->
integer
(
'query_type'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'query'
);
}
}
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