initial commit
This commit is contained in:
72
app/Http/Controllers/Auth/AuthController.php
Normal file
72
app/Http/Controllers/Auth/AuthController.php
Normal 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']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Auth/PasswordController.php
Normal file
32
app/Http/Controllers/Auth/PasswordController.php
Normal 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');
|
||||
}
|
||||
}
|
||||
14
app/Http/Controllers/Controller.php
Normal file
14
app/Http/Controllers/Controller.php
Normal 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;
|
||||
}
|
||||
29
app/Http/Controllers/HomeController.php
Normal file
29
app/Http/Controllers/HomeController.php
Normal 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');
|
||||
}
|
||||
}
|
||||
36
app/Http/Controllers/LoginController.php
Normal file
36
app/Http/Controllers/LoginController.php
Normal 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'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
594
app/Http/Controllers/admin/AdminController.php
Normal file
594
app/Http/Controllers/admin/AdminController.php
Normal 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
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user