Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
21e5b4f
Table User
ngothuyhoa Jul 5, 2018
57f74de
Update Table User
ngothuyhoa Jul 5, 2018
e615e5b
Update User and Topic
ngothuyhoa Jul 5, 2018
6a85c2b
Upadate User and Topic L2
ngothuyhoa Jul 7, 2018
8099800
Merge pull request #7 from ngothuyhoa/kbv1-buildAdmin
toanmv-1729 Jul 7, 2018
56446e7
Pull code
toanmv-1729 Jul 7, 2018
ad23dbf
fix conflict
toanmv-1729 Jul 7, 2018
e007247
Some bug
toanmv-1729 Jul 7, 2018
895dae9
Done AdminPost
toanmv-1729 Jul 9, 2018
3d37537
Done basic CRUD topic,post,user,advertisement
toanmv-1729 Jul 10, 2018
4c35517
Merge pull request #9 from maivantoan0808/kbv1-buildAdmin
toanmv-1729 Jul 10, 2018
c1770b7
Done Basic Login,Register,Reset,Middleware
toanmv-1729 Jul 10, 2018
1fb9ff9
cut layouts
0henri0 Jul 15, 2018
2eceee3
Fix some bugs
toanmv-1729 Jul 16, 2018
8fb0667
Make some thing in pages user
toanmv-1729 Jul 16, 2018
4bd62b2
Merge branch 'kbv1-buildAdmin' into buildPages
toanmv-1729 Jul 16, 2018
01a5b07
Merge pull request #15 from maivantoan0808/buildPages
toanmv-1729 Jul 16, 2018
fd97df7
send mail
0henri0 Jul 17, 2018
07667c8
revert code
0henri0 Jul 17, 2018
6c562f2
them notify cho trang chu, them sua post va delete post,
0henri0 Jul 17, 2018
19f0ec8
search index, send mail
0henri0 Jul 17, 2018
ae152c3
Merge pull request #16 from 0henri0/kbv1-buildAdmin
toanmv-1729 Jul 18, 2018
e4e5214
Fix Migration and something else
toanmv-1729 Jul 25, 2018
eb83d61
Fix migration and something else
toanmv-1729 Jul 25, 2018
ff1e96f
Merge pull request #17 from maivantoan0808/buildPages
toanmv-1729 Jul 25, 2018
aeee431
Send Mail by notification and queues
0henri0 Jul 25, 2018
94dbe04
modify config and data UpdatePost
0henri0 Jul 25, 2018
47839c9
modify mail done!
0henri0 Jul 25, 2018
a9e3010
Merge pull request #18 from 0henri0/kbv1-buildAdmin
0henri0 Jul 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Homestead.yaml
npm-debug.log
yarn-error.log
.env
/upload
116 changes: 116 additions & 0 deletions app/Function/checkextension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php
// Mở composer.json
// Thêm vào trong "/autoload" chuỗi sau
// "files": [
// "app/function/checkextension.php"
// ]

// Chạy cmd : composer dumpautoload
// follow extension: https://www.computerhope.com/issues/ch001789.htm
//
function checkExtensionArchive($ext){
$extArchive = [
'a',
'ar',
'iso',
'tar',
'bz2',
'gz',
'lz',
'lzma',
'rz',
'sfark',
'sz',
'xz',
'z',
'7z',
's7z',
'ace',
'apk',
'arc',
'jar',
'rar',
'tzx',
'zip',
'zipx',
'zpaq',
'zz',
'tar.gz',
'rpm',
'arj',
'deb',
'pkg',
'z'
];
if(in_array(strtolower($ext), $extArchive))
return true;
return false;
}

function checkExtensionSupportFile($ext){
$extSup = [
// rich text
'',
'doc',
'docx',
'odt',
'pdf',
'rtf',
'tex',
'txt',
'wks',
'wps',
'wpd',
// spreadsheet
'ods',
'xlr',
'xls',
'xlsx',
// presentation
'key',
'odp',
'pps',
'ppt',
'pptx'
];
if(in_array(strtolower($ext), $extSup))
return true;
return false;
}

function checkExtensionImage($ext){
$extImg = [
'ai',
'bmp',
'gif',
'ico',
'jpeg',
'jpg',
'png',
'ps',
'psd',
'svg',
'tif',
'tiff'
];
if(in_array(strtolower($ext), $extImg))
return true;
return false;
}

function getUrlFileUpload($ext,$str){
if(checkExtensionArchive($ext)) return "archive/{$str}";
if(checkExtensionImage($ext)) return "images/{$str}";
if(checkExtensionSupportFile($ext)) return "document/{$str}";
return $str;
}

function getExtension($file){
$len = strlen($file);
for($i = $len-1; $i >= 0; $i--){
if($file[$i] == '.') {
return substr($file, $i-$len+1);
}
}
}
?>
8 changes: 8 additions & 0 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Http\Controllers;

class AdminController extends Controller
{

}
139 changes: 139 additions & 0 deletions app/Http/Controllers/AdvertisementController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php

namespace App\Http\Controllers;

use App\Models\Advertisement;
use Illuminate\Http\Request;

class AdvertisementController extends Controller
{
// Display list advertisement
public function getList()
{
$advertisement = Advertisement::all();

return view('admin.advertisement.list', ['advertisement' => $advertisement]);
}

// Call to view new create advertisement
public function getCreate()
{

return view('admin.advertisement.create');
}

// Create new advertisement
public function postCreate(Request $request)
{
$this->validate($request,
[
'name' => 'required|min:3|unique:advertisement,name',
'urlad' => 'required|min:10',

],
[
'name.required' => 'You have not filled out NAME ADVERTISEMENT yet',
'name.min' => 'NAME ADVERTISEMENT must be at least 3 characters',
'name.unique' => 'NAME ADVERTISEMENT Existed',
'urlad.required' => 'You have not filled out URL ADVERTISEMENT yet',
'urlad.min' => 'URL ADVERTISEMENT must be at least 10 characters and started by http:// or https://',
]
);
$postCreate = new Advertisement;
$postCreate->name = $request->name;
$postCreate->urladvertisement = $request->urlad;

if ($request->hasFile('imgad')) {
$img = $request->file('imgad');
$ext = $img->getClientOriginalExtension();
if (!checkExtensionImage($ext)) {

return redirect('admin/post/create')->with('error', 'DO NOT SUPPORT THIS FORMAT!');
}
$urlimage = substr(time() . mt_rand() . '_' . $img->getClientOriginalName(), -190);
while (file_exists('upload/images/imgad/' . $urlimage)) {
$urlimage = substr(time() . mt_rand() . '_' . $img->getClientOriginalName(), -190);
}
$img->move('upload/images/imgad', $urlimage);
$postCreate->urlimage = $urlimage;
} else {
$postCreate->urlimage = 'default.jpg';
}
$postCreate->save();

return redirect('admin/advertisement/list')->with('notify', 'Create successful : ' . $request->name);
}

// Display form update advertisement
public function getUpdate($id)
{
$advertisement = Advertisement::find($id);

return view('admin.advertisement.update', ['advertisement' => $advertisement]);
}

// Update advertisement
public function postUpdate(Request $request, $id)
{
$postUpdate = Advertisement::find($id);
$this->validate($request,
[
'name' => 'required|min:3',
'urlad' => 'required|min:10',

],
[
'name.required' => 'You have not filled out NAME ADVERTISEMENT yet',
'name.min' => 'NAME ADVERTISEMENT must be at least 3 characters',
'urlad.required' => 'You have not filled out URL ADVERTISEMENT yet',
'urlad.min' => 'URL ADVERTISEMENT must be at least 10 characters and started by http:// or https://',
]
);

if ($request->name != null) {
$postUpdate->name = $request->name;
}

if ($request->urlad != null) {
$postUpdate->urladvertisement = $request->urlad;
}

if ($request->hasFile('imgad')) {
$img = $request->file('imgad');
$ext = $img->getClientOriginalExtension();
if (!checkExtensionImage($ext)) {

return redirect('admin/update/advertisement/$id')->with('error', 'DO NOT SUPPORT THIS FORMAT!');
}
$urlimage = substr(time() . mt_rand() . '_' . $img->getClientOriginalName(), -190);
while (file_exists('upload/images/imgad/' . $urlimage)) {
$urlimage = substr(time() . mt_rand() . '_' . $img->getClientOriginalName(), -190);
}
$img->move('upload/images/imgad', $urlimage);
if ($postUpdate->urlimage != 'default.jpg' && file_exists('upload/images/imgad/' . $advertisement->urlimage)) {
unlink('upload/images/imgad/' . $postUpdate->urlimage);
}

$postUpdate->urlimage = $urlimage;
}

$postUpdate->save();

return redirect('admin/advertisement/list')->with('notify', 'Update successful : ' . $request->name);
}

// Delete advertisement
public function getDelete($id)
{
$deleteAdvertisement = Advertisement::find($id);
//save nametopic before delete to show
$nameAd = $deleteAdvertisement->name;
$urlimage = $deleteAdvertisement->urlimage;
if ($urlimage != 'default.jpg' && file_exists('upload/images/imgad/' . $urlimage)) {
unlink('upload/images/imgad/' . $urlimage);
}
$deleteAdvertisement->delete();

return redirect('admin/advertisement/list')->with('notify', 'Delete successful : ' . $nameAd);
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
Expand All @@ -16,7 +17,7 @@ class LoginController extends Controller
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
*/

use AuthenticatesUsers;

Expand All @@ -25,7 +26,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin/dashboard';

/**
* Create a new controller instance.
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Auth;

use App\User;
use App\Models\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
Expand All @@ -28,7 +28,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';

/**
* Create a new controller instance.
Expand All @@ -50,6 +50,7 @@ protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'username' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
Expand All @@ -65,6 +66,7 @@ protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'username' => $data['username'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';

/**
* Create a new controller instance.
Expand Down
26 changes: 26 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Http\Controllers;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('/');
}
}
Loading