initial commit

This commit is contained in:
Frank John Begornia
2019-10-29 19:29:28 +08:00
commit d225ff22d4
7623 changed files with 740861 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}

30
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
// Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
}

8
app/Events/Event.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
namespace App\Events;
abstract class Event
{
//
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
class Controller extends BaseController
{
use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
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('home');
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Auth;
use Validator;
use Redirect;
class LoginController extends Controller
{
public function authenticate(Request $request) {
$post = $request->all();
$email = $post['email'];
$password = $post['password'];
if (Auth::attempt(['email' => $email, 'password' => $password])) {
// Authentication passed...
if (Auth::user()->role == 'admin') {
// return $next($request);
return redirect()->intended('admin');
}
return redirect('/logout');
}else{
return Redirect::back()->withErrors(array(
'error'=>'Invalid Email Address or Password'
));
}
}
}

View File

@@ -0,0 +1,594 @@
<?php
namespace App\Http\Controllers\admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\admin\AdminModel;
use Illuminate\Support\Facades\Storage;
use Validator;
use App\User;
class AdminController extends Controller
{
public function dashboard(){
return view('admin_pages.dashboard');
}
public function orders(){
$AdminModel = new AdminModel;
$array_payment_details = $AdminModel->selectPaymentDetails('All', null);
return view('admin_pages.orders')
->with('array_payment_details', $array_payment_details);
}
public function viewOrders($ck){
$AdminModel = new AdminModel;
// $array_shipping_add = null;
$order_item_array = $AdminModel->selectOrderItem('CartKey', $ck);
$item_goup_array = $AdminModel->itemGroup($ck);
$item_thumbs = $AdminModel->selectDisplayItemThumb();
$array_payment_details = $AdminModel->selectPaymentDetails('CartKey', $ck);
$array_shipping_add = $AdminModel->selectShippingAddress('PaymentDetail_Id', $array_payment_details[0]->Id);
return view('admin_pages.order_details')
->with('array_payment_details', $array_payment_details)
->with('img_thumb', $item_thumbs)
->with('item_goup_array', $item_goup_array)
->with('order_item_array', $order_item_array)
->with('array_shipping_add', $array_shipping_add);
}
public function createStore(){
$AdminModel = new AdminModel;
return view('admin_pages.create_store');
}
public function printOrder($ck){
$AdminModel = new AdminModel;
// $array_shipping_add = null;
$order_item_array = $AdminModel->selectOrderItem('CartKey', $ck);
$item_goup_array = $AdminModel->itemGroup($ck);
$item_thumbs = $AdminModel->selectDisplayItemThumb();
$array_payment_details = $AdminModel->selectPaymentDetails('CartKey', $ck);
$array_shipping_add = $AdminModel->selectShippingAddress('PaymentDetail_Id', $array_payment_details[0]->Id);
return view('admin_pages.print_order')
->with('array_payment_details', $array_payment_details)
->with('img_thumb', $item_thumbs)
->with('item_goup_array', $item_goup_array)
->with('order_item_array', $order_item_array)
->with('array_shipping_add', $array_shipping_add);
}
public function downloadPrintFile_tshirt($dc, $id){
$AdminModel = new AdminModel;
$client_design_array = $AdminModel->selectClientDesign($dc);
$order_item_array = $AdminModel->selectOrderItem('Id', $id);
return view('admin_pages.download_pages.tshirt')
->with('client_design_array', $client_design_array)
->with('order_item_array', $order_item_array);
}
public function downloadPrintFile_jersey($dc, $id){
$AdminModel = new AdminModel;
$client_design_array = $AdminModel->selectClientDesign($dc);
$order_item_array = $AdminModel->selectOrderItem('Id', $id);
// var_dump($order_item_array);
return view('admin_pages.download_pages.jersey')
->with('client_design_array', $client_design_array)
->with('order_item_array', $order_item_array);
}
public function download(Request $request){
$post = $request->all();
$svgText = $post['svgText'];
$filename = $post['filename'];
header('Content-type: image/svg+xml');
header('Content-Disposition: attachment; filename="'.$filename.'.svg"');
echo '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
print "$svgText";
}
public function saveNewStore(Request $request){
$post = $request->all();
$AdminModel = new AdminModel;
$store_name = $post['store_name'];
$store_url = $post['store_url'];
if($post['store_status'] == "Public"){
$store_status = "true";
}else{
$store_status = "false";
}
if(isset($post['set_store_password'])){
$store_password = $post['store_password'];
}else{
$store_password = null;
}
$check_store_url = array(
'StoreUrl' => $store_url
);
$validator = Validator::make($check_store_url, [
'StoreUrl' => 'unique:teamstores'
],
[
'StoreUrl.unique' => 'The Store URL has already been taken.',
]);
if ($validator->fails())
{
$errors = "";
foreach($validator->errors()->all() as $error){
$errors .= "<li>".$error."</li>";
}
return response()->json(array(
'success' => false,
'clearform' => false,
'message' => $errors
));
}
$store_logo_name = 'logo.'. $request->file('store_logo')->getClientOriginalExtension();
$store_banner_name = 'banner.'. $request->file('store_banner')->getClientOriginalExtension();
$data = array(
'StoreUrl' => $store_url,
'ImageFolder' => $store_url,
'Password' => $store_password,
'HashId' => md5($store_url),
'StoreName' => $store_name,
'StoreLogo' => $store_logo_name,
'StoreBanner' => $store_banner_name,
'IsActive' => $store_status
);
$res = $AdminModel->insertTeamstore($data);
if($res){
Storage::disk('uploads')->put('/teamstore/'. $store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
Storage::disk('uploads')->put('/teamstore/'. $store_url . '/' . $store_banner_name, fopen($request->file('store_banner'), 'r+'));
return response()->json(array(
'success' => true,
'clearform' => true,
'message'=>'Store is successfully created.'
));
}else{
return response()->json(array(
'success' => false,
'clearform' => true,
'message' => 'Something went wrong. Please refresh the page and try again.'
));
}
}
public function storeList(){
$AdminModel = new AdminModel;
$q = null;
$sort = null;
$q = request()->get('q');
$sort = request()->get('s'); // sort
if(isset($q) && isset($sort)){
if($sort == "al-asc"){
$field = "StoreName";
$sort_value = "ASC";
}elseif($sort == "al-desc"){
$field = "StoreName";
$sort_value = "DESC";
}else{
$field = "Id";
$sort_value = "ASC";
}
if($q != ""){
// keyword and sort
$teamstore_array = $AdminModel->selectTeamstoreSearch($field, $sort_value, $q);
}else{
// sort only
$teamstore_array = $AdminModel->selectTeamstoreFilter($field, $sort_value);
}
}else{
// first load
$teamstore_array = $AdminModel->selectTeamstore();
}
return view('admin_pages.list_of_stores')
->with('teamstore_array', $teamstore_array)
->with('keyword', $q)
->with('filter', $sort);
}
public function viewStore($id){
$AdminModel = new AdminModel;
$teamstore_array = $AdminModel->selectTeamstoreById($id);
$store_owners_array = $AdminModel->selectStoreOwners($id);
return view('admin_pages.edit_store')
->with('teamstore_array', $teamstore_array)
->with('store_owners_array', $store_owners_array);
}
public function updateStore(Request $request){
$post = $request->all();
$AdminModel = new AdminModel;
$store_id = $post['store_id'];
$store_name = $post['store_name'];
$store_url = $post['store_url'];
$orig_store_url = $post['orig_store_url'];
$store_currency = $post['store_currency'];
if($post['store_status'] == "Public"){
$store_status = "true";
}else{
$store_status = "false";
}
if(isset($post['set_store_password'])){
$store_password = $post['store_password'];
}else{
$store_password = null;
}
if($request->file('store_logo') != null){
$store_logo_name = 'logo.'. $request->file('store_logo')->getClientOriginalExtension();
}else{
$store_logo_name = $post['orig_store_logo'];
}
if($request->file('store_banner') != null){
$store_banner_name = 'banner.'. $request->file('store_banner')->getClientOriginalExtension();
}else{
$store_banner_name = $post['orig_store_banner'];
}
if($orig_store_url != $store_url){
$check_store_url = array(
'StoreUrl' => $store_url
);
$validator = Validator::make($check_store_url, [
'StoreUrl' => 'unique:teamstores'
],
[
'StoreUrl.unique' => 'The Store URL has already been taken.',
]);
if ($validator->fails())
{
$errors = "";
foreach($validator->errors()->all() as $error){
$errors .= "<li>".$error."</li>";
}
return response()->json(array(
'success' => false,
'clearform' => false,
'message' => $errors
));
}
}
$data = array(
'StoreUrl' => $store_url,
// 'ImageFolder' => $store_url,
'Password' => $store_password,
'HashId' => md5($store_url),
'StoreName' => $store_name,
'StoreLogo' => $store_logo_name,
'StoreBanner' => $store_banner_name,
'StoreCurrency' => $store_currency,
'IsActive' => $store_status
);
// var_dump($data);
$res = $AdminModel->updateTeamstore($store_id, $data);
// var_dump($res);
// if($res){
if($request->file('store_logo') != null){
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_logo_name, fopen($request->file('store_logo'), 'r+'));
}
if($request->file('store_banner') != null){
Storage::disk('uploads')->put('/teamstore/'. $orig_store_url . '/' . $store_banner_name, fopen($request->file('store_banner'), 'r+'));
}
return response()->json(array(
'success' => true,
'clearform' => false,
'message'=>'Store is successfully updated.'
));
// }else{
// return response()->json(array(
// 'success' => false,
// 'clearform' => true,
// 'message' => 'Something went wrong. Please refresh the page and try again.'
// ));
// }
}
public function deleteStore(Request $request){
$AdminModel = new AdminModel;
$post = $request->all();
$teamstore_array = $AdminModel->selectTeamstoreById($post['id']);
if($teamstore_array[0]->StoreUrl == $post['store_url']){
$res = $AdminModel->deleteTeamstoreById($post['id']);
if($res){
return response()->json(array(
'success' => true,
'message' => 'This Store is successfully deleted.'
));
}else{
return response()->json(array(
'success' => false,
'message' => 'Something went wrong. Please refresh the page and try again.'
));
}
}else{
return response()->json(array(
'success' => false,
'message' => 'Something went wrong. Please refresh the page and try again.'
));
}
}
public function overlayPattern(){
$AdminModel = new AdminModel;
$pattern_array = $AdminModel->selectPattern();
return view('admin_pages.overlay_pattern')
->with('pattern_array', $pattern_array);
}
public function viewOverlayPattern($id){
$AdminModel = new AdminModel;
$pattern_array = $AdminModel->selectPatternWithfield('Id', $id);
return view('admin_pages.edit_overlay_pattern')
->with('pattern_array', $pattern_array);
}
public function viewReports(){
return view('admin_pages.reports');
}
public function viewClipart(){
$AdminModel = new AdminModel;
$clipart_categories_array = $AdminModel->selectClipartCategory();
return view('admin_pages.clipart')
->with('clipart_categories_array', $clipart_categories_array);
}
public function saveClipartCategory(Request $request){
$post = $request->all();
$AdminModel = new AdminModel;
$data = array(
'CategoryName' => $post['category'],
'IsActive' => $post['is_active']
);
$res = $AdminModel->insertClipartCategory($data);
if($res){
return response()->json(array(
'success' => true,
'addClass'=> 'modal-close-reload',
'message' => 'Clipart Category is successfully added.'
));
}else{
return response()->json(array(
'success' => false,
'addClass'=> '',
'message' => 'Something went wrong. Please refresh the page and try again.'
));
}
}
public function saveSVGClipart(Request $request){
$post = $request->all();
$AdminModel = new AdminModel;
$getSVGData = $post['svg_data'];
$category = $post['category'];
$tags = $post['tags'];
$orig_filename = $post['filename'];
var_dump($request->file('svg_data'));
// $lower_filename = str_replace(' ','-',strtolower($orig_filename));
// $getExt = substr($request->file('svg_data')->getClientOriginalExtension());
// $clean_filename = preg_replace("/\.[^.\s]{3,4}$/", "", $lower_filename);
// $final_filename = $clean_filename . "-".uniqid().$getExt;
// $q1 = $conn->prepare("INSERT INTO cliparts (CategoryId, OriginalSVGFilename, SVGFilename, Tags, IsActive) VALUES (:cat_id, :orig_name, :svg_name, :tags, :is_act)");
// $q1->execute(array(':cat_id'=>$category, ':orig_name'=>$orig_filename, ':svg_name'=>$final_filename, 'tags'=>$tags, ':is_act'=>0));
// $svg = new DOMDocument('1.0', 'UTF-8');
// $svg->xmlStandalone = false;
// $svg->loadXML($getSVGData);
// $file = $clipartFolder . $final_filename;
// file_put_contents($file, $svg->saveXML());
// echo '
// <script>
// alert("File is successfully uploaded");
// window.location = "./";
// </script>
// ';
// $data = array(
// 'CategoryName' => $post['category'],
// 'IsActive' => $post['is_active']
// );
// $res = $AdminModel->insertClipartCategory($data);
// if($res){
// return response()->json(array(
// 'success' => true,
// 'addClass'=> 'modal-close-reload',
// 'message' => 'Clipart Category is successfully added.'
// ));
// }else{
// return response()->json(array(
// 'success' => false,
// 'addClass'=> '',
// 'message' => 'Something went wrong. Please refresh the page and try again.'
// ));
// }
}
function userList(){
$AdminModel = new AdminModel;
$result = $AdminModel->userList();
// var_dump( $result);
return response()->json([
"count" => count($result),
"results" => $result
]);
}
function updatUserAsStoreOwner(Request $request){
$AdminModel = new AdminModel;
$data = array(
'user_id' => $request->user_id,
'store_id' => $request->store_id
);
$res = $AdminModel->makeUserAsStoreOwner($data);
return response()->json([
"result" => $res
]);
}
public function removeStoreAccess(Request $request){
$AdminModel = new AdminModel;
$data = array(
'user_id' => $request->id,
'store_id' => null
);
$res = $AdminModel->model_removeStoreAccess($data);
return response()->json([
"result" => $res
]);
}
public function saveNewStoreOwner(Request $request){
$AdminModel = new AdminModel;
$post = $request->all();
$validator = Validator::make($post, [
'username' => 'unique:user_logins',
'email' => 'unique:user_logins'
]);
if ($validator->fails())
{
$errors = "";
foreach($validator->errors()->all() as $error){
$errors .= "<li>".$error."</li>";
}
$message = '
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-ban"></i> ERROR:</h4>
'.$errors.
'</div>';
return response()->json(array(
'success' => false,
'message' => $message
));
}
User::create([
'name' => $post['name'],
'username' => $post['username'],
'email' => $post['email'],
'password' => bcrypt($post['password']),
'role' => 'store_owner',
'store_id' => $post['store_id'],
]);
return response()->json(array(
'success' => true
));
}
}

55
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\Cors::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'admin' => \App\Http\Middleware\IsAdmin::class,
];
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
return $next($request);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS')
->header('Access-Control-Allow-Headers', 'Content-Type, Authorizations');
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
class EncryptCookies extends BaseEncrypter
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Auth;
class IsAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::user() && Auth::user()->role == 'admin') {
return $next($request);
}
return redirect()->back();
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
}
return $next($request);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest
{
//
}

69
app/Http/routes.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::post('/custom/auth', 'LoginController@authenticate');
Route::post('/custom/register', 'CustomAuthController@postRegister');
Route::group(['middleware' => 'auth'], function () {
Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function () {
Route::get('/', 'admin\AdminController@dashboard');
Route::get('orders', 'admin\AdminController@orders');
Route::get('orders/view/{ck}', 'admin\AdminController@viewOrders');
Route::get('orders/view/{ck}/print', 'admin\AdminController@printOrder');
Route::get('create-store', 'admin\AdminController@createStore');
Route::post('orders/download', 'admin\AdminController@download');
Route::post('create-store/save', 'admin\AdminController@saveNewStore');
Route::get('stores-list', 'admin\AdminController@storeList');
Route::get('view-store/{id}', 'admin\AdminController@viewStore');
Route::post('store/update', 'admin\AdminController@updateStore');
Route::post('store/delete/{id}/{url}', 'admin\AdminController@deleteStore');
Route::get('overlay-pattern', 'admin\AdminController@overlayPattern');
Route::get('overlay-pattern', 'admin\AdminController@overlayPattern');
Route::get('reports', 'admin\AdminController@viewReports');
Route::get('clipart', 'admin\AdminController@viewClipart');
Route::post('clipart/save-category', 'admin\AdminController@saveClipartCategory');
Route::post('clipart/save-svg-clipart', 'admin\AdminController@saveSVGClipart');
Route::get('user-list', 'admin\AdminController@userList');
Route::post('post/update-user-as-store-owner', 'admin\AdminController@updatUserAsStoreOwner');
Route::post('post/remove-store-access', 'admin\AdminController@removeStoreAccess');
Route::post('post/save-new-store-owner', 'admin\AdminController@saveNewStoreOwner');
// Download Routes /////////////////
Route::get('orders/download/tshirt/{ck}/{id}', 'admin\AdminController@downloadPrintFile_tshirt');
Route::get('orders/download/jersey/{ck}/{id}', 'admin\AdminController@downloadPrintFile_jersey');
// End Download Routes /////////////
});
});
Route::auth();
// Route::get('/home', 'HomeController@index');

21
app/Jobs/Job.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
abstract class Job
{
/*
|--------------------------------------------------------------------------
| Queueable Jobs
|--------------------------------------------------------------------------
|
| This job base class provides a central location to place any logic that
| is shared across all of your jobs. The trait included with the class
| provides access to the "onQueue" and "delay" queue helper methods.
|
*/
use Queueable;
}

1
app/Listeners/.gitkeep Normal file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,187 @@
<?php
namespace App\Models\admin;
use Illuminate\Database\Eloquent\Model;
use DB;
class AdminModel extends Model
{
function selectPaymentDetails($field, $value){
if($field != "All"){
$i = DB::table('payment_details')
->where($field, $value)
->orderby('Id', 'ASC')
->get();
}else{
$i = DB::table('payment_details')
->orderby('Id', 'ASC')
->get();
}
return $i;
}
function selectOrderItem($field, $ck){
$i = DB::table('orders')
->where($field, $ck)
->get();
return $i;
}
function itemGroup($cartKey){
$pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM orders WHERE CartKey = :ck GROUP BY ProductId");
$query->execute([':ck'=>$cartKey]);
$row = $query->fetchAll(\PDO::FETCH_OBJ);
return $row;
}
function selectDisplayItemThumb(){
$i = DB::table('teamstore_product_thumbnails')
->where('ImageClass', 'active')
->get();
return $i;
}
function selectShippingAddress($field, $value){
$i = DB::table('shipping_addresses')
->where($field, $value)
->get();
return $i;
}
function selectClientDesign($design_code){
$i = DB::table('client_designs')
->where('DesignCode', $design_code)
->get();
return $i;
}
function insertTeamstore($data){
$i = DB::table('teamstores')->insert($data);
return $i;
}
function selectTeamstore(){
$i = DB::table('teamstores')
->paginate(16);
return $i;
}
function selectTeamstoreFilter($field, $value){
$i = DB::table('teamstores')
->orderby($field, $value)
->paginate(16);
return $i;
}
function selectTeamstoreSearch($field, $value, $keyword){
$i = DB::table('teamstores')
->where("StoreName", "LIKE","%$keyword%")
->orderby($field, $value)
->paginate(16);
return $i;
}
function selectTeamstoreById($id){
$i = DB::table('teamstores')
->where("Id", $id)
->get();
return $i;
}
function updateTeamstore($id, $data){
$i = DB::table('teamstores')
->where("Id", $id)
->update($data);
return $i;
}
function deleteTeamstoreById($id){
$i = DB::table('teamstores')
->where("Id", $id)
->delete();
return $i;
}
function selectPattern(){
$i = DB::table('patterns')
->get();
return $i;
}
function selectPatternWithfield($field, $value){
$i = DB::table('patterns')
->where($field, $value)
->get();
return $i;
}
function selectClipartCategory(){
$i = DB::table('clipart_categories')
->leftjoin('user_logins', 'clipart_categories.UserId', '=', 'user_logins.id')
->select('clipart_categories.*', 'user_logins.username')
->orderby('clipart_categories.Ordering', 'ASC')
->get();
return $i;
}
function selectStoreOwners($store_id){
$i = DB::table('user_logins')
->where('role', 'store_owner')
->where('store_id', $store_id)
->get();
return $i;
}
function insertClipartCategory($data){
$i = DB::table('clipart_categories')->insert($data);
return $i;
}
function userList(){
$i = DB::table('user_logins')
->select('id', 'name', 'username', 'email')
// ->where("name", "LIKE","%$keyword%")
// ->orWhere("username", "LIKE","%$keyword%")
// ->orWhere("email", "LIKE","%$keyword%")
->where("role", "user")
->orderby('name', 'ASC')
->get();
return $i;
}
function makeUserAsStoreOwner($data){
$i = DB::table('user_logins')
->where("Id", $data['user_id'])
->update(['role'=> 'store_owner', 'store_id'=> $data['store_id']]);
return $i;
}
function model_removeStoreAccess($data){
$i = DB::table('user_logins')
->where("Id", $data['user_id'])
->update(['role'=> 'user', 'store_id'=> $data['store_id']]);
return $i;
}
}

1
app/Policies/.gitkeep Normal file
View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Providers;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies($gate);
//
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$this->mapWebRoutes($router);
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
}

28
app/User.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $table = 'user_logins';
protected $fillable = [
'name', 'username', 'email', 'password', 'role', 'store_id'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}