Compare commits

..

14 Commits

Author SHA1 Message Date
df7cabf43f PARAG-69 2020-01-13 16:51:49 +00:00
3148041bf9 PARAG-66, PARAG-67 2020-01-13 16:50:57 +00:00
aff4727298 PARAG-65 2020-01-13 16:50:18 +00:00
cc3ab941c9 PARAG-64 2020-01-13 16:50:00 +00:00
950ca6605a PARAG-57, PARAG-59 2020-01-13 16:49:05 +00:00
5a5d1a33b8 Prześlij pliki do ''
PARAG-61, PARAG-58
2020-01-13 16:47:02 +00:00
48dfedd9b3 Upload files to '' 2020-01-13 16:37:32 +00:00
b6d1ffa623 PARAG-39 make Barcode image on barcode string from request 2019-12-16 13:10:05 +01:00
749f6b6415 PARAG-44 Store register blade 2019-12-16 13:07:38 +01:00
d2e1051a7a PARAG-43 Store login blade 2019-12-16 13:06:23 +01:00
3f64e933be PARAG-42 User Login API 2019-12-16 13:04:01 +01:00
c7e85999cd PARAG-40 Store Register API 2019-12-16 13:02:21 +01:00
d7fe21bc80 PARAG-41 Store login with API 2019-12-16 13:00:42 +01:00
62b1895a34 PARAG-26 Register Controller 2019-12-09 16:22:29 +01:00
48 changed files with 2084 additions and 148 deletions

22
Category.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
public function receipt_items()
{
return $this->belongsTo('App\Models\ReceiptItem');
}
public function services()
{
return $this->belongsToMany('App\Models\Service', 'categories_services', 'category_id', 'service_id')->withTimestamps();;
}
protected $hidden = [
'pivot'
];
}

10
CategoryService.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CategoryService extends Model
{
}

52
LoginController.php Normal file
View File

@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//$this->middleware('guest')->except('logout');
}
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 202);
}
}
}

25
Receipt.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Receipt extends Model
{
protected $fillable = ['id', 'payment_date', 'payment_amount', 'user_id', 'store_id', 'created_at', 'updated_at'];
public function user()
{
return $this->belongsTo('App\User');
}
public function store()
{
return $this->belongsTo('App\User');
}
public function receipt_items()
{
return $this->hasMany('App\Models\ReceiptItem');
}
}

131
ReceiptController.php Normal file
View File

@ -0,0 +1,131 @@
<?php
namespace App\Http\Controllers;
use App\Models\Receipt;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ReceiptController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(Receipt::with('receipt_items')->where('user_id', Auth::guard('api')->user()->id)->get(), 200);
}
else{
return response()->json(["message " => "User auth failed."], 404);
}
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
$receipt = Receipt::create([
'payment_date' => $request->payment_date,
'payment_amount' => $request->payment_amount,
'user_id' => $this->findUserByBarcode($request->barcode),
'store_id' => Auth::guard('store')->check() ? Auth::guard('store')->user()->id : null,
]);
}
else{
return response()->json(["message " => "Store auth failed."], 404);
}
return response()->json($receipt, 201);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Request $request, $id)
{
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
$receipt = Receipt::with('receipt_items')->where('user_id', Auth::guard('api')->user()->id)->get()->find($id);
if(is_null($receipt)){ return response()->json(["message " => "Record not found."], 404);}
return response()->json($receipt, 200);
}
else{
return response()->json(["message " => "User auth failed."], 404);
}
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
$receipt = Receipt::find($id);
if(is_null($receipt)){ return response()->json(["message " => "Record not found."], 404);}
$receipt->update($request->all());
return response()->json($receipt, 200);
}
else{
return response()->json(["message " => "Store auth failed."], 404);
}
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
$receipt = Receipt::where('store_id', Auth::id())->get()->find($id);
if(is_null($receipt)){ return response()->json(["message " => "Record not found."], 404);}
$receipt->delete();
return response()->json(null, 204);
}
else{
return response()->json(["message " => "User auth failed."], 404);
}
}
public function findUserByBarcode($barcode)
{
$user = User::where('barcode', $barcode)->first();
$id = $user->id;
return $id;
}
}

21
ReceiptItem.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ReceiptItem extends Model
{
protected $table = 'receipt_items';
protected $fillable = ['id', 'name', 'price', 'quantity' , 'receipt_id', 'category_id', 'created_at', 'updated_at'];
public function receipts()
{
return $this->belongsTo('App\Models\Receipt');
}
public function categories()
{
return $this->hasMany('App\Models\Category');
}
}

110
RegisterController.php Normal file
View File

@ -0,0 +1,110 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Picqer;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
public function makeBarcodeExample(Request $request)
{
$label = $request->barcode;
$barcode_generator = new Picqer\Barcode\BarcodeGeneratorPNG();
$barcode = $barcode_generator->getBarcode($label, $barcode_generator::TYPE_CODE_128);
echo '<img src="data:image/png;base64,' . base64_encode($barcode) . '">';
echo '<p>'.$label;
}
public function makeBarcode(Request $request)
{
$label = $request->barcode;
$barcode_generator = new Picqer\Barcode\BarcodeGeneratorPNG();
$barcode = $barcode_generator->getBarcode($label, $barcode_generator::TYPE_CODE_128);
echo '<img src="data:image/png;base64,' . base64_encode($barcode) . '">';
echo '<p>'.$label;
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'barcode' => ['required', 'string'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function createAPI(Request $request)
{
if($user = User::where('email', $request->email)->exists())
{
return response()->json(["message " => "User exists."], 404);
}
else
{
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return response()->json($user, 201);
}
}
protected function create(array $data)
{
#self::makeBarcode($data['barcode']);
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}

46
Service.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Service extends Authenticatable
{
use Notifiable;
protected $guard = "service";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'id', 'name', 'street', 'city', 'vovivodeship', 'longitude', 'latitude', 'created_at', 'updated_at', 'email', 'password'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'pivot'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function users()
{
return $this->belongsToMany('App\Models\Category', 'categories_services')->withTimestamps();;
}
}

35
ServiceController.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers;
use App\Models\Category;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ServiceController extends Controller
{
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function showByCategory(Request $request, $category)
{
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
$id = Category::where('name', $category)->first()->id;
$services = Category::find($id)->services;
if(is_null($services)){ return response()->json(["message " => "Record not found."], 404);}
return response()->json($services, 200);
}
else{
return response()->json(["message " => "User auth failed."], 404);
}
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class ServiceLoginController extends Controller
{
public function __construct(){
//$this->middleware('guest:store');
}
public function showLoginForm(){
return view('auth.service-login');
}
public function login(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('service')->attempt([
'email' => $request->email,
'password' => $request->password], $request->remember))
{
return redirect()->intended(route('service.dashboard'));
}
return redirect()->back();
}
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('service')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 404);
}
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Models\Service;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ServiceRegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:services'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function createAPI(Request $request)
{
if($service = Service::where('email', $request->email)->exists())
{
return response()->json(["message " => "Service exists."], 404);
}
else
{
$service = Service::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return response()->json($service, 201);
}
}
protected function create(Request $request)
{
$service = Service::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
if(Auth::guard('service')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return redirect()->intended(route('service.dashboard'));
}
}
public function showRegisterForm(){
return view('auth.service-register');
}
}

52
StoreLoginController.php Normal file
View File

@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class StoreLoginController extends Controller
{
public function __construct(){
//$this->middleware('guest:store');
}
public function showLoginForm(){
return view('auth.store-login');
}
public function login(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password], $request->remember))
{
return redirect()->intended(route('store.dashboard'));
}
return redirect()->back();
}
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 404);
}
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Models\Store;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class StoreRegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:stores'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function createAPI(Request $request)
{
if($store = Store::where('email', $request->email)->exists())
{
return response()->json(["message " => "Store exists."], 404);
}
else
{
$store = Store::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return response()->json($store, 201);
}
}
protected function create(Request $request)
{
$store = Store::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return redirect()->intended(route('store.dashboard'));
}
}
public function showRegisterForm(){
return view('auth.store-register');
}
}

41
api.php Normal file
View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::prefix('user')->group(function(){
Route::post('/login', 'Auth\LoginController@loginAPI');
Route::post('/register', 'Auth\RegisterController@createAPI');
Route::get('/receipt', 'ReceiptController@index');
Route::get('/receipt/{id}', 'ReceiptController@show');
Route::get('/servicesByCategory/{category}', 'ServiceController@showByCategory');
});
Route::prefix('store')->group(function(){
Route::post('login', 'Auth\StoreLoginController@loginAPI');
Route::post('register', 'Auth\StoreRegisterController@createAPI');
Route::post('/receipt', 'ReceiptController@store');
Route::put('/receipt/{id}', 'ReceiptController@update');
Route::delete('/receipt/{id}', 'ReceiptController@destroy');
});
Route::prefix('service')->group(function(){
Route::post('login', 'Auth\ServiceLoginController@loginAPI');
Route::post('register', 'Auth\ServiceRegisterController@createAPI');
});
Route::apiResource('receiptItem', 'ReceiptItemController');

BIN
arrow.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

BIN
back.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

BIN
back1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

33
code.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="style.css"/>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
</head>
<body>
<script src="JsBarcode.all.min.js"></script>
<span style="font-size:26px; font-style: bold; display: block; margin-bottom:30px;">dominika_g</span>
<span style="font-size:20px; font-style: bold; padding-top: 80px;">Pokaż kod przy zakupie</span>
<div class="listbox" style="padding-top:100px; width:70%;margin-top:70px;">
<span style="font-size: 25px; display: block;"> Dominika Grajewska </span><br/><br/>
<span style="font-size: 20px; display: block;">numer klienta</span><br/>
<span style="font-size: 20px; display: block;">0028674567</span>
<script>window.setTimeout(function(){
JsBarcode("#barcode", "0028674567", {
lineColor: "#000000",
width: 2,
height: 200,
background: "rgba(255,255,255,0.4)",
displayValue: true
});
}, 0);</script>
<svg id="barcode" style="margin-top:20px">adas</svg>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

1
debug.log Normal file
View File

@ -0,0 +1 @@
[1209/172729.308:ERROR:settings.cc(320)] Settings magic is not 1129342067

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 B

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<link rel="stylesheet" href="style.css"/>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<body>
<span style="font-size:20px;">Przypomnij hasło</span>
<form action="/action_page.php">
<div class="bord"><image class="icon" src="lock.png"></image><input type="email" required class="prostokat" placeholder="e-mail">
</input>
</div>
<button type="submit">
<image src="arrow.png" width="30px">
</button>
</form>
</body>

View File

@ -1,62 +0,0 @@
body {
background-image: url("back.png");
background-repeat: no-repeat;
background-size: 500px;
text-align: center;
max-width:500px;
margin-left:0px;
margin-top: 50px;
color: white;
font-family: 'Raleway', sans-serif;
}
.prostokat{
float: right;
width: 85%;
height: 40px;
background-color: white;
opacity: 0.9;
}
input{
border: none;
font-size: 20px;
color: #613559;
}
.icon{
margin-top:3px;
width:12%;
height:85%;
}
.bord{
border: solid white 3px;
width:65%;
height: 40px;
margin: auto;
opacity:0.9;
margin-top:30px;
}
button{
background: none;
border:none;
margin-top:20px;
}
input::placeholder{
text-align: center;
font-size: 20px;
color: #613559;
text-transform: uppercase;
}
a{
text-decoration: none;
color: white;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

130
guarant.html Normal file
View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<link rel="stylesheet" href="style.css"/>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<body>
<script>
// document.body.onload = addElement;
function addHeader() {
var newDivhead = document.createElement("div");
var shop = document.createTextNode("EURO RTV AGD");
var date = document.createTextNode("24-03-1996");
var xshop = document.createElement("h3");
var xdate = document.createElement("h3");
xshop.classList.add("headboxmap");
xdate.classList.add("dateboxmap");
xshop.appendChild(shop);
xdate.appendChild(date);
newDivhead.appendChild(xshop);
newDivhead.appendChild(xdate);
var currentDiv = document.getElementById("div2");
document.body.insertBefore(newDivhead, currentDiv);
}
function addElement () {
// create a new div element
var newDiv = document.createElement("div");
// and give it some content
var price = document.createTextNode("$ 123zł");
var prod = document.createTextNode("2 szt.");
var device = document.createTextNode("Pralka BOSH Z345-5TRQ");
var xprice = document.createElement("SPAN");
var xprod = document.createElement("SPAN");
var xdevice = document.createElement("SPAN");
xprice.classList.add("pricemap");
xprod.classList.add("numbmap");
xdevice.classList.add("devicemap");
xprice.appendChild(price);
xprod.appendChild(prod);
xdevice.appendChild(device);
newDiv.appendChild(xdevice);
newDiv.appendChild(xprod);
newDiv.appendChild(document.createElement("br"));
newDiv.appendChild(document.createElement("br"));
newDiv.classList.add("listbox");
var image = document.createElement("img");
var image2 = document.createElement("img");
image.id = "id";
image.className = "mapimg";
image.src = "pin.png"; // image.src = "IMAGE URL/PATH"
newDiv.appendChild(image);
image2.id = "id";
image2.className = "mapimg2";
image2.src = "cont.png"; // image.src = "IMAGE URL/PATH"
newDiv.appendChild(image2);
newDiv.appendChild(xprice);
var currentDiv = document.getElementById("div1");
document.body.insertBefore(newDiv, currentDiv);
}
</script>
<div class="headmap"> <script> addHeader(); </script> </div>
<script> addElement(); </script>
<div class="listbox">
<div id="gdate"> gwarancja ważna do: </div> <br/><br/>
<span id="time" style="font-weight: bold;"> Okres gwarancji: </span> <br/><br/>
<span id="yes"> Gwarancja obejmuje: </span> <br/><br/>
<span id="no"> Gwarancja nie obejmuje: </span>
</div>
<script>function guaranty (){
var sdate = document.getElementById("gdate");
var stime = document.getElementById("time");
var gdate = document.createTextNode("22-09-2022");
sdate.appendChild(gdate);
var time = document.createTextNode("2 lata");
stime.appendChild(time);
var yes = [["uszczelki"],
["szkło"],
["pokrywę wierzchnią"]];
var no = [["uszczelki"],
["szkło"],
["pokrywę wierzchnią"]];
}
guaranty();
</script>
</body>

View File

@ -1,6 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<head>
<link rel="stylesheet" href="style.css"/> <link rel="stylesheet" href="style.css"/>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<script src="JsBarcode.all.js"></script>
<script src="main.js"></script>
</head>
<body> <body>
<span style="font-size:20px;">Zaloguj się</span> <span style="font-size:20px;">Zaloguj się</span>
<form action="/action_page.php"> <form action="/action_page.php">
@ -19,6 +23,18 @@
<span style="font-size:20px;">Zarejestruj się</span> <span style="font-size:20px;">Zarejestruj się</span>
<form action="/action_page.php"> <form action="/action_page.php">
<div class="bord"><image class="icon" src="name.png"></image><input type="text" class="prostokat" placeholder="imię">
</input>
</div>
<div class="bord"><image class="icon" src="name.png"></image><input type="text" class="prostokat" placeholder="nazwisko">
</input>
</div>
<div class="bord"><image class="icon" src="user.png"></image><input type="text" class="prostokat" placeholder="login"> <div class="bord"><image class="icon" src="user.png"></image><input type="text" class="prostokat" placeholder="login">
</input> </input>

View File

@ -2,8 +2,11 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller class LoginController extends Controller
{ {
@ -36,4 +39,21 @@ class LoginController extends Controller
{ {
$this->middleware('guest')->except('logout'); $this->middleware('guest')->except('logout');
} }
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 404);
}
}
} }

View File

@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Picqer;
class RegisterController extends Controller class RegisterController extends Controller
{ {
@ -40,18 +42,35 @@ class RegisterController extends Controller
$this->middleware('guest'); $this->middleware('guest');
} }
/** public function makeBarcodeExample(Request $request)
* Get a validator for an incoming registration request. {
* $label = $request->barcode;
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator $barcode_generator = new Picqer\Barcode\BarcodeGeneratorPNG();
*/ $barcode = $barcode_generator->getBarcode($label, $barcode_generator::TYPE_CODE_128);
echo '<img src="data:image/png;base64,' . base64_encode($barcode) . '">';
echo '<p>'.$label;
}
public function makeBarcode(Request $request)
{
$label = $request->barcode;
$barcode_generator = new Picqer\Barcode\BarcodeGeneratorPNG();
$barcode = $barcode_generator->getBarcode($label, $barcode_generator::TYPE_CODE_128);
echo '<img src="data:image/png;base64,' . base64_encode($barcode) . '">';
echo '<p>'.$label;
}
protected function validator(array $data) protected function validator(array $data)
{ {
return Validator::make($data, [ return Validator::make($data, [
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'], 'password' => ['required', 'string', 'min:8', 'confirmed'],
'barcode' => ['required', 'string'],
]); ]);
} }
@ -61,8 +80,21 @@ class RegisterController extends Controller
* @param array $data * @param array $data
* @return \App\User * @return \App\User
*/ */
protected function createAPI(Request $request)
{
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return response()->json($user, 201);
}
protected function create(array $data) protected function create(array $data)
{ {
#self::makeBarcode($data['barcode']);
return User::create([ return User::create([
'name' => $data['name'], 'name' => $data['name'],
'email' => $data['email'], 'email' => $data['email'],

View File

@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class StoreLoginController extends Controller
{
public function __construct(){
$this->middleware('guest:store');
}
public function showLoginForm(){
return view('auth.store-login');
}
public function login(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password], $request->remember))
{
return redirect()->intended(route('store.dashboard'));
}
return redirect()->back();
}
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 404);
}
}
}

View File

@ -0,0 +1,90 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Models\Store;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class StoreRegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function createAPI(Request $request)
{
$store = Store::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
return response()->json($store, 201);
}
protected function create(Request $request)
{
$store = Store::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
if(Auth::guard('store')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return redirect()->intended(route('store.dashboard'));
}
}
public function showRegisterForm(){
return view('auth.store-register');
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
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\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StoreController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth:store');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('store');
}
}

View File

@ -19,6 +19,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Barryvdh\Cors\HandleCors::class,
]; ];
/** /**

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class AuthBasic
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(Auth::onceBasic()){
return response()->json(["message " => "Auth failed."], 404);
}
else{
return $next($request);
}
}
}

View File

@ -2,10 +2,44 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Store extends Model class Store extends Authenticatable
{ {
use Notifiable;
protected $guard = 'store';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function post() public function post()
{ {
return $this->hasMany('App\Models\Receipt'); return $this->hasMany('App\Models\Receipt');

View File

@ -37,9 +37,9 @@ class User extends Authenticatable
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
public function receipts() public function receipts()
{ {
return $this->hasMany('App\Models\Receipt'); return $this->hasMany('App\Models\Receipt');
} }
} }

View File

@ -40,11 +40,17 @@ return [
'driver' => 'session', 'driver' => 'session',
'provider' => 'users', 'provider' => 'users',
], ],
'api' => [ 'api' => [
'driver' => 'token', 'driver' => 'session',
'provider' => 'users', 'provider' => 'users',
'hash' => false, ],
'store' => [
'driver' => 'session',
'provider' => 'stores',
],
'store-api' => [
'driver' => 'session',
'provider' => 'stores',
], ],
], ],
@ -71,10 +77,10 @@ return [
'model' => App\User::class, 'model' => App\User::class,
], ],
// 'users' => [ 'stores' => [
// 'driver' => 'database', 'driver' => 'eloquent',
// 'table' => 'users', 'model' => App\Models\Store::class,
// ], ],
], ],
/* /*
@ -98,6 +104,11 @@ return [
'table' => 'password_resets', 'table' => 'password_resets',
'expire' => 60, 'expire' => 60,
], ],
'stores' => [
'provider' => 'stores',
'table' => 'password_resets',
'expire' => 60,
],
], ],
]; ];

View File

@ -0,0 +1,304 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
/*
|--------------------------------------------------------------------------
| JWT Authentication Secret
|--------------------------------------------------------------------------
|
| Don't forget to set this in your .env file, as it will be used to sign
| your tokens. A helper command is provided for this:
| `php artisan jwt:secret`
|
| Note: This will be used for Symmetric algorithms only (HMAC),
| since RSA and ECDSA use a private/public key combo (See below).
|
*/
'secret' => env('JWT_SECRET'),
/*
|--------------------------------------------------------------------------
| JWT Authentication Keys
|--------------------------------------------------------------------------
|
| The algorithm you are using, will determine whether your tokens are
| signed with a random string (defined in `JWT_SECRET`) or using the
| following public & private keys.
|
| Symmetric Algorithms:
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
| Asymmetric Algorithms:
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
*/
'keys' => [
/*
|--------------------------------------------------------------------------
| Public Key
|--------------------------------------------------------------------------
|
| A path or resource to your public key.
|
| E.g. 'file://path/to/public/key'
|
*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| A path or resource to your private key.
|
| E.g. 'file://path/to/private/key'
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
],
/*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour.
|
| You can also set this to null, to yield a never expiring token.
| Some people may want this behaviour for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
|
*/
'ttl' => env('JWT_TTL', 60),
/*
|--------------------------------------------------------------------------
| Refresh time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate.
| Defaults to 2 weeks.
|
| You can also set this to null, to yield an infinite refresh time.
| Some may want this instead of never expiring tokens for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
|
*/
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
/*
|--------------------------------------------------------------------------
| JWT hashing algorithm
|--------------------------------------------------------------------------
|
| Specify the hashing algorithm that will be used to sign the token.
|
| See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
| for possible values.
|
*/
'algo' => env('JWT_ALGO', 'HS256'),
/*
|--------------------------------------------------------------------------
| Required Claims
|--------------------------------------------------------------------------
|
| Specify the required claims that must exist in any token.
| A TokenInvalidException will be thrown if any of these claims are not
| present in the payload.
|
*/
'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
/*
|--------------------------------------------------------------------------
| Persistent Claims
|--------------------------------------------------------------------------
|
| Specify the claim keys to be persisted when refreshing a token.
| `sub` and `iat` will automatically be persisted, in
| addition to the these claims.
|
| Note: If a claim does not exist then it will be ignored.
|
*/
'persistent_claims' => [
// 'foo',
// 'bar',
],
/*
|--------------------------------------------------------------------------
| Lock Subject
|--------------------------------------------------------------------------
|
| This will determine whether a `prv` claim is automatically added to
| the token. The purpose of this is to ensure that if you have multiple
| authentication models e.g. `App\User` & `App\OtherPerson`, then we
| should prevent one authentication request from impersonating another,
| if 2 tokens happen to have the same id across the 2 different models.
|
| Under specific circumstances, you may want to disable this behaviour
| e.g. if you only have one authentication model, then you would save
| a little on token size.
|
*/
'lock_subject' => true,
/*
|--------------------------------------------------------------------------
| Leeway
|--------------------------------------------------------------------------
|
| This property gives the jwt timestamp claims some "leeway".
| Meaning that if you have any unavoidable slight clock skew on
| any of your servers then this will afford you some level of cushioning.
|
| This applies to the claims `iat`, `nbf` and `exp`.
|
| Specify in seconds - only if you know you need it.
|
*/
'leeway' => env('JWT_LEEWAY', 0),
/*
|--------------------------------------------------------------------------
| Blacklist Enabled
|--------------------------------------------------------------------------
|
| In order to invalidate tokens, you must have the blacklist enabled.
| If you do not want or need this functionality, then set this to false.
|
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| When multiple concurrent requests are made with the same JWT,
| it is possible that some of them fail, due to token regeneration
| on every request.
|
| Set grace period in seconds to prevent parallel request failure.
|
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/*
|--------------------------------------------------------------------------
| Cookies encryption
|--------------------------------------------------------------------------
|
| By default Laravel encrypt cookies for security reason.
| If you decide to not decrypt cookies, you will have to configure Laravel
| to not encrypt your cookie token by adding its name into the $except
| array available in the middleware "EncryptCookies" provided by Laravel.
| see https://laravel.com/docs/master/responses#cookies-and-encryption
| for details.
|
| Set it to true if you want to decrypt cookies.
|
*/
'decrypt_cookies' => false,
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
| Specify the various providers used throughout the package.
|
*/
'providers' => [
/*
|--------------------------------------------------------------------------
| JWT Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to create and decode the tokens.
|
*/
'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
/*
|--------------------------------------------------------------------------
| Authentication Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to authenticate users.
|
*/
'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
/*
|--------------------------------------------------------------------------
| Storage Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to store tokens in the blacklist.
|
*/
'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
],
];

View File

@ -0,0 +1,92 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row">
<label for="barcode" class="col-md-4 col-form-label text-md-right">{{ __('Barcode') }}</label>
<div class="col-md-6">
<input id="barcode" type="text" class="form-control @error('barcode') is-invalid @enderror" name="barcode" value="{{ old('barcode') }}" required autocomplete="barcode" autofocus>
@error('barcode')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,73 @@
@extends('layouts.storeapp')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Store Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('store.login.submit') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,77 @@
@extends('layouts.storeapp')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('store.register.submit') }}">
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
You are logged in!
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
@if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
<main class="py-4">
@yield('content')
</main>
</div>
</body>
</html>

View File

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('store.login') }}">{{ __('Login') }}</a>
</li>
@if (Route::has('store.register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('store.register') }}">{{ __('Register') }}</a>
</li>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
<main class="py-4">
@yield('content')
</main>
</div>
</body>
</html>

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Store Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
You are logged as Store!
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -13,7 +13,15 @@ use Illuminate\Http\Request;
| |
*/ */
#Route::apiResource('/receipt', 'ReceiptController'); Route::prefix('user')->group(function(){
Route::post('login', 'Auth\LoginController@loginAPI');
Route::post('register', 'Auth\RegisterController@createAPI');
});
Route::prefix('store')->group(function(){
Route::post('login', 'Auth\StoreLoginController@loginAPI');
Route::post('register', 'Auth\StoreRegisterController@createAPI');
});
Route::middleware('auth:api')->get('/user', function (Request $request) { Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user(); return $request->user();

View File

@ -14,3 +14,19 @@
Route::get('/', function () { Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
# Barcode example
Route::get('barcode', 'Auth\RegisterController@makeBarcodeExample');
Route::prefix('store')->group(function(){
Route::get('/login', 'Auth\StoreLoginController@showLoginForm')->name('store.login');
Route::post('/login', 'Auth\StoreLoginController@login')->name('store.login.submit');
Route::get('/register', 'Auth\StoreRegisterController@showRegisterForm')->name('store.register');
Route::post('/register', 'Auth\StoreRegisterController@create')->name('store.register.submit');
Route::get('/', 'StoreController@index')->name('store.dashboard');
});