mirror of
https://github.com/brunofontes/shareit.git
synced 2025-04-11 06:40:48 +00:00
Compare commits
No commits in common. "v0.5" and "master" have entirely different histories.
8
.gitignore
vendored
8
.gitignore
vendored
@ -5,14 +5,8 @@
|
|||||||
/vendor
|
/vendor
|
||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
/.vagrant
|
|
||||||
Homestead.json
|
|
||||||
Homestead.yaml
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
.env
|
.env
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
mergeAndDeploy.sh
|
tags
|
||||||
start_vagrant.sh
|
|
||||||
stop_vagrant.sh
|
|
||||||
ssh_homestead.sh
|
|
||||||
|
53
app/Events/RefreshPage.php
Normal file
53
app/Events/RefreshPage.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use \App\Item;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class RefreshPage implements ShouldBroadcastNow
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item
|
||||||
|
*
|
||||||
|
* @var Item
|
||||||
|
*/
|
||||||
|
public $item;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Item $item)
|
||||||
|
{
|
||||||
|
$this->item = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['touchedItem'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'RefreshPage';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,24 +3,29 @@
|
|||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use \App\Item;
|
use \App\Item;
|
||||||
use Illuminate\Broadcasting\Channel;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Broadcasting\PrivateChannel;
|
|
||||||
use Illuminate\Broadcasting\PresenceChannel;
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class ReturnItem
|
class ReturnItem
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item
|
||||||
|
*
|
||||||
|
* @var Item
|
||||||
|
*/
|
||||||
public $item;
|
public $item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @param Item $item The returned item.
|
* @param Item $item The returned item.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(Item $item)
|
public function __construct(Item $item)
|
||||||
@ -35,6 +40,11 @@ class ReturnItem
|
|||||||
*/
|
*/
|
||||||
public function broadcastOn()
|
public function broadcastOn()
|
||||||
{
|
{
|
||||||
return new PrivateChannel('channel-name');
|
return new PrivateChannel('touchedItem');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'ReturnItem';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Exceptions;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
@ -32,7 +33,7 @@ class Handler extends ExceptionHandler
|
|||||||
* @param \Exception $exception
|
* @param \Exception $exception
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function report(Exception $exception)
|
public function report(Throwable $exception)
|
||||||
{
|
{
|
||||||
parent::report($exception);
|
parent::report($exception);
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ class Handler extends ExceptionHandler
|
|||||||
* @param \Exception $exception
|
* @param \Exception $exception
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $exception)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use Mail;
|
|
||||||
use \App\User;
|
|
||||||
use \App\Mail\UserWaiting;
|
use \App\Mail\UserWaiting;
|
||||||
|
use \App\User;
|
||||||
|
use App\FlashMessage;
|
||||||
|
use Auth;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Mail;
|
||||||
|
|
||||||
class AlertController extends Controller
|
class AlertController extends Controller
|
||||||
{
|
{
|
||||||
@ -16,15 +17,25 @@ class AlertController extends Controller
|
|||||||
* the item is free
|
* the item is free
|
||||||
*
|
*
|
||||||
* @param Request $request Form data
|
* @param Request $request Form data
|
||||||
*
|
*
|
||||||
* @return redirect to home
|
* @return redirect to home
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$item = User::loggedIn()->items()->find(request('item'));
|
$item = User::loggedIn()->items()->find(request('item'));
|
||||||
$item->waiting_user_id = Auth::id();
|
if (!$item->used_by) {
|
||||||
$item->timestamps = false;
|
session()->flash(
|
||||||
$item->save();
|
FlashMessage::PRIMARY,
|
||||||
|
__('Oh! This item has just being returned. Take it before anyone else!')
|
||||||
|
);
|
||||||
|
return redirect('home');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item->used_by == Auth::id()) {
|
||||||
|
return redirect('home');
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->storeAlert();
|
||||||
|
|
||||||
$loggedUser = Auth::user()->name;
|
$loggedUser = Auth::user()->name;
|
||||||
$userWithItem = User::find($item->used_by);
|
$userWithItem = User::find($item->used_by);
|
||||||
@ -38,10 +49,12 @@ class AlertController extends Controller
|
|||||||
public function delete(Request $request)
|
public function delete(Request $request)
|
||||||
{
|
{
|
||||||
$item = User::loggedIn()->items()->find(request('item'));
|
$item = User::loggedIn()->items()->find(request('item'));
|
||||||
$item->waiting_user_id = null;
|
|
||||||
$item->timestamps = false;
|
|
||||||
$item->save();
|
|
||||||
|
|
||||||
|
if ($item->waiting_user_id != Auth::id()) {
|
||||||
|
return redirect('home');
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->removeAlert();
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\User;
|
use App\FlashMessage;
|
||||||
use App\Mail\Welcome;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Mail\Welcome;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
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 App\FlashMessage;
|
|
||||||
use Mail;
|
use Mail;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
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\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
{
|
{
|
||||||
|
@ -42,14 +42,14 @@ class HomeController extends Controller
|
|||||||
->groupBy('product.name');
|
->groupBy('product.name');
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'home',
|
'home',
|
||||||
['products' => $products, 'users' => $this->activeUsers, 'usedItems' => $numberOfUsedItems]
|
['products' => $products, 'users' => $this->activeUsers, 'usedItems' => $numberOfUsedItems]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the username from an specified user id.
|
* Get the username from an specified user id.
|
||||||
*
|
*
|
||||||
* @param object $itemUsers Array with IDs and usernames
|
* @param object $itemUsers Array with IDs and usernames
|
||||||
* @param int $id The user id to search for
|
* @param int $id The user id to search for
|
||||||
*
|
*
|
||||||
|
@ -4,8 +4,8 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use \App\Item;
|
use \App\Item;
|
||||||
use \App\User;
|
use \App\User;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\FlashMessage as flash;
|
use App\FlashMessage as flash;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ItemController extends Controller
|
class ItemController extends Controller
|
||||||
{
|
{
|
||||||
@ -13,7 +13,8 @@ class ItemController extends Controller
|
|||||||
{
|
{
|
||||||
$item = Item::find($id);
|
$item = Item::find($id);
|
||||||
if (!$item || $item->product->user_id != \Auth::id()) {
|
if (!$item || $item->product->user_id != \Auth::id()) {
|
||||||
session()->flash(flash::DANGER,
|
session()->flash(
|
||||||
|
flash::DANGER,
|
||||||
\Lang::getFromJson(
|
\Lang::getFromJson(
|
||||||
"The item doesn't exist."
|
"The item doesn't exist."
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App;
|
use App;
|
||||||
use Lang;
|
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use \App\Item;
|
use \App\Item;
|
||||||
use \App\User;
|
|
||||||
use \App\Product;
|
use \App\Product;
|
||||||
use Illuminate\Http\Request;
|
use \App\User;
|
||||||
use App\FlashMessage as flash;
|
use App\FlashMessage as flash;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class ProductController extends Controller
|
class ProductController extends Controller
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ class ProductController extends Controller
|
|||||||
|
|
||||||
if (!$product) {
|
if (!$product) {
|
||||||
session()->flash(
|
session()->flash(
|
||||||
flash::DANGER,
|
flash::DANGER,
|
||||||
\Lang::getFromJson(
|
\Lang::getFromJson(
|
||||||
"The product doesn't exist or doesn't belongs to you."
|
"The product doesn't exist or doesn't belongs to you."
|
||||||
)
|
)
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
use App\Events\RefreshPage;
|
||||||
use Lang;
|
use App\Events\ReturnItem;
|
||||||
use App\Item;
|
use App\Item;
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\Events\ReturnItem;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible to Take and Return an Item.
|
* Responsible to Take and Return an Item.
|
||||||
@ -18,19 +18,22 @@ class TakeController extends Controller
|
|||||||
* The user take an item
|
* The user take an item
|
||||||
*
|
*
|
||||||
* @param Request $request The form data
|
* @param Request $request The form data
|
||||||
*
|
*
|
||||||
* @return home view
|
* @return home view
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$item = User::loggedIn()->items()->find(request('item'));
|
$item = User::loggedIn()->items()->find(request('item'));
|
||||||
if ($item->used_by) {
|
|
||||||
|
try {
|
||||||
|
$item->takeItem();
|
||||||
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(
|
return back()->withErrors(
|
||||||
Lang::getFromJson("This item is already taken")
|
Lang::getFromJson('This item is already taken')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$item->used_by = Auth::id();
|
|
||||||
$item->save();
|
RefreshPage::dispatch($item);
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,14 +42,23 @@ class TakeController extends Controller
|
|||||||
* Trigger an event: ReturnItem
|
* Trigger an event: ReturnItem
|
||||||
*
|
*
|
||||||
* @param Request $request Form data
|
* @param Request $request Form data
|
||||||
*
|
*
|
||||||
* @return View home
|
* @return View home
|
||||||
*/
|
*/
|
||||||
public function delete(Request $request)
|
public function delete(Request $request)
|
||||||
{
|
{
|
||||||
$item = User::loggedIn()->items()->find(request('item'));
|
$item = User::loggedIn()->items()->find(request('item'));
|
||||||
event(new ReturnItem($item));
|
|
||||||
$item->returnItem();
|
try {
|
||||||
|
$item->returnItem();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->withErrors(
|
||||||
|
Lang::getFromJson("You cannot return an item that is not with you")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshPage::dispatch($item);
|
||||||
|
ReturnItem::dispatch($item);
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use \Lang;
|
|
||||||
use \App\User;
|
|
||||||
use \App\Item;
|
use \App\Item;
|
||||||
use \App\Product;
|
use \App\User;
|
||||||
|
use \Lang;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
|
@ -51,7 +51,7 @@ class Kernel extends HttpKernel
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $routeMiddleware = [
|
protected $middlewareAliases = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
|
||||||
|
|
||||||
class TrustProxies extends Middleware
|
class TrustProxies extends Middleware
|
||||||
{
|
{
|
||||||
@ -19,5 +19,10 @@ class TrustProxies extends Middleware
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
}
|
}
|
||||||
|
51
app/Item.php
51
app/Item.php
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Exception;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Item extends Model
|
class Item extends Model
|
||||||
@ -31,23 +33,66 @@ class Item extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the items from logged in user
|
* Return the items from logged in user
|
||||||
*
|
*
|
||||||
* @return \App\Item
|
* @return \App\Item
|
||||||
*/
|
*/
|
||||||
public static function fromAuthUser()
|
public static function fromAuthUser()
|
||||||
{
|
{
|
||||||
return (new static)->where('user_id', \Auth::id());
|
return (new static)->where('user_id', Auth::id());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a specified item
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function takeItem()
|
||||||
|
{
|
||||||
|
if (isset($this->used_by)) {
|
||||||
|
throw new Exception("Trying to take an Item that is in use", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->used_by = Auth::id();
|
||||||
|
$this->waiting_user_id = null;
|
||||||
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a specified item
|
* Return a specified item
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function returnItem()
|
public function returnItem()
|
||||||
{
|
{
|
||||||
|
if ($this->used_by != Auth::id()) {
|
||||||
|
throw new Exception("Trying to return an empty Item or from other user", 1);
|
||||||
|
}
|
||||||
|
|
||||||
$this->used_by = null;
|
$this->used_by = null;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a waiting user to the item
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function storeAlert()
|
||||||
|
{
|
||||||
|
$this->waiting_user_id = Auth::id();
|
||||||
|
$this->timestamps = false;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a waiting user to the item
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function removeAlert()
|
||||||
|
{
|
||||||
$this->waiting_user_id = null;
|
$this->waiting_user_id = null;
|
||||||
|
$this->timestamps = false;
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use Mail;
|
|
||||||
use App\User;
|
|
||||||
use App\Events\ReturnItem;
|
use App\Events\ReturnItem;
|
||||||
use App\Mail\ItemAvailable;
|
use App\Mail\ItemAvailable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use App\User;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Mail;
|
||||||
|
|
||||||
class AlertReturnedItem
|
class AlertReturnedItem
|
||||||
{
|
{
|
||||||
@ -26,7 +24,7 @@ class AlertReturnedItem
|
|||||||
* is waiting for the item
|
* is waiting for the item
|
||||||
*
|
*
|
||||||
* @param ReturnItem $event The return event that contains an item
|
* @param ReturnItem $event The return event that contains an item
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle(ReturnItem $event)
|
public function handle(ReturnItem $event)
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
use IlluminateAuthEventsLogin;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Auth\Events\Login;
|
use Illuminate\Auth\Events\Login;
|
||||||
|
use IlluminateAuthEventsLogin;
|
||||||
|
|
||||||
class SetLanguage
|
class SetLanguage
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,6 @@ use \App\Item;
|
|||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
|
|
||||||
class ItemAvailable extends Mailable
|
class ItemAvailable extends Mailable
|
||||||
{
|
{
|
||||||
@ -33,8 +32,8 @@ class ItemAvailable extends Mailable
|
|||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
return $this->subject(
|
return $this->subject(
|
||||||
\Lang::getFromJson(
|
\Lang::get(
|
||||||
':itemname is available!',
|
':itemname is available!',
|
||||||
['itemname' => $this->item->name]
|
['itemname' => $this->item->name]
|
||||||
)
|
)
|
||||||
)->markdown('emails.itemAvailable');
|
)->markdown('emails.itemAvailable');
|
||||||
|
@ -2,18 +2,17 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
use Lang;
|
|
||||||
use \App\Item;
|
use \App\Item;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Lang;
|
||||||
|
|
||||||
class UserWaiting extends Mailable
|
class UserWaiting extends Mailable
|
||||||
{
|
{
|
||||||
public $item;
|
public $item;
|
||||||
public $waitingUser;
|
public $waitingUser;
|
||||||
public $userWithItem;
|
public $userWithItem;
|
||||||
use Queueable, SerializesModels;
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,10 +35,10 @@ class UserWaiting extends Mailable
|
|||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
return $this->subject(
|
return $this->subject(
|
||||||
Lang::getFromJson(
|
Lang::get(
|
||||||
':waitinguser wants to use :itemname',
|
':waitinguser wants to use :itemname',
|
||||||
[
|
[
|
||||||
'waitinguser' => $this->waitingUser,
|
'waitinguser' => $this->waitingUser,
|
||||||
'itemname' => $this->item->name
|
'itemname' => $this->item->name
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
use \Lang;
|
|
||||||
use \App\User;
|
use \App\User;
|
||||||
|
use \Lang;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
|
|
||||||
class Welcome extends Mailable
|
class Welcome extends Mailable
|
||||||
{
|
{
|
||||||
@ -31,6 +30,6 @@ class Welcome extends Mailable
|
|||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
return $this->subject(Lang::getFromJson('Welcome'))->markdown('emails.welcome');
|
return $this->subject(Lang::get('Welcome'))->markdown('emails.welcome');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class Product extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the products from logged in user
|
* Return the products from logged in user
|
||||||
*
|
*
|
||||||
* @return \App\Product
|
* @return \App\Product
|
||||||
*/
|
*/
|
||||||
public static function fromAuthUser()
|
public static function fromAuthUser()
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191); //Solved by increasing StringLength
|
Schema::defaultStringLength(191); //Solved by increasing StringLength
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
@ -23,7 +22,6 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
use Illuminate\Support\Facades\Broadcast;
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class BroadcastServiceProvider extends ServiceProvider
|
class BroadcastServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Events\ReturnItem;
|
use App\Events\ReturnItem;
|
||||||
use App\Listeners\SetLanguage;
|
|
||||||
use App\Listeners\AlertReturnedItem;
|
use App\Listeners\AlertReturnedItem;
|
||||||
use Illuminate\Support\Facades\Event;
|
use App\Listeners\SetLanguage;
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
class EventServiceProvider extends ServiceProvider
|
class EventServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
class RouteServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Notifications\Notifiable;
|
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Support\Facades\Request;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class User extends Authenticatable implements MustVerifyEmail
|
class User extends Authenticatable implements MustVerifyEmail
|
||||||
{
|
{
|
||||||
@ -42,7 +41,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the logged in user
|
* Return the logged in user
|
||||||
*
|
*
|
||||||
* @return \App\User
|
* @return \App\User
|
||||||
*/
|
*/
|
||||||
public static function loggedIn()
|
public static function loggedIn()
|
||||||
@ -53,7 +52,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
/**
|
/**
|
||||||
* Set the default website language
|
* Set the default website language
|
||||||
* for the acual user
|
* for the acual user
|
||||||
*
|
*
|
||||||
* @param string $language The language code
|
* @param string $language The language code
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
2
check.sh
Normal file
2
check.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
./vendor/bin/phpstan analyse --memory-limit=2G
|
||||||
|
php artisan insights
|
@ -5,18 +5,24 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^8.0.2",
|
||||||
"fideloper/proxy": "^4.0",
|
"inertiajs/inertia-laravel": "^0.6.11",
|
||||||
"laravel/framework": "5.7.*",
|
"laravel/framework": "^10.0",
|
||||||
"laravel/tinker": "^1.0"
|
"laravel/ui": "^4.0",
|
||||||
|
"laravel/helpers": "^1.4",
|
||||||
|
"laravel/tinker": "^2.4.1",
|
||||||
|
"pusher/pusher-php-server": "^7.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"beyondcode/laravel-dump-server": "^1.0",
|
"beyondcode/laravel-dump-server": "^1.0",
|
||||||
"filp/whoops": "^2.0",
|
"filp/whoops": "^2.0",
|
||||||
"fzaninotto/faker": "^1.4",
|
"fzaninotto/faker": "^1.4",
|
||||||
"mockery/mockery": "^1.0",
|
"mockery/mockery": "^1.0",
|
||||||
"nunomaduro/collision": "^2.0",
|
"nunomaduro/collision": "^7.0",
|
||||||
"phpunit/phpunit": "^7.0"
|
"nunomaduro/larastan": "^2.9.5",
|
||||||
|
"nunomaduro/phpinsights": "*",
|
||||||
|
"phpstan/phpstan": "^1.10.66",
|
||||||
|
"phpunit/phpunit": "^10.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
@ -53,8 +59,11 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"optimize-autoloader": true
|
"optimize-autoloader": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
9405
composer.lock
generated
9405
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -156,7 +156,7 @@ return [
|
|||||||
*/
|
*/
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
App\Providers\AuthServiceProvider::class,
|
App\Providers\AuthServiceProvider::class,
|
||||||
// App\Providers\BroadcastServiceProvider::class,
|
App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
|
||||||
|
113
config/insights.php
Normal file
113
config/insights.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenDefineFunctions;
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenFinalClasses;
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses;
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenPrivateMethods;
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Insights\ForbiddenTraits;
|
||||||
|
use NunoMaduro\PhpInsights\Domain\Metrics\Architecture\Classes;
|
||||||
|
use SlevomatCodingStandard\Sniffs\Commenting\UselessFunctionDocCommentSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\TypeHints\DisallowMixedTypeHintSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSniff;
|
||||||
|
use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Preset
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default preset that will be used by PHP Insights
|
||||||
|
| to make your code reliable, simple, and clean. However, you can always
|
||||||
|
| adjust the `Metrics` and `Insights` below in this configuration file.
|
||||||
|
|
|
||||||
|
| Supported: "default", "laravel", "symfony", "magento2", "drupal"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'preset' => 'laravel',
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| IDE
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This options allow to add hyperlinks in your terminal to quickly open
|
||||||
|
| files in your favorite IDE while browsing your PhpInsights report.
|
||||||
|
|
|
||||||
|
| Supported: "textmate", "macvim", "emacs", "sublime", "phpstorm",
|
||||||
|
| "atom", "vscode".
|
||||||
|
|
|
||||||
|
| If you have another IDE that is not in this list but which provide an
|
||||||
|
| url-handler, you could fill this config with a pattern like this:
|
||||||
|
|
|
||||||
|
| myide://open?url=file://%f&line=%l
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'ide' => null,
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may adjust all the various `Insights` that will be used by PHP
|
||||||
|
| Insights. You can either add, remove or configure `Insights`. Keep in
|
||||||
|
| mind that all added `Insights` must belong to a specific `Metric`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'exclude' => [
|
||||||
|
// 'path/to/directory-or-file'
|
||||||
|
],
|
||||||
|
|
||||||
|
'add' => [
|
||||||
|
Classes::class => [
|
||||||
|
ForbiddenFinalClasses::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'remove' => [
|
||||||
|
AlphabeticallySortedUsesSniff::class,
|
||||||
|
DeclareStrictTypesSniff::class,
|
||||||
|
DisallowMixedTypeHintSniff::class,
|
||||||
|
ForbiddenDefineFunctions::class,
|
||||||
|
ForbiddenNormalClasses::class,
|
||||||
|
ForbiddenTraits::class,
|
||||||
|
ParameterTypeHintSniff::class,
|
||||||
|
PropertyTypeHintSniff::class,
|
||||||
|
ReturnTypeHintSniff::class,
|
||||||
|
UselessFunctionDocCommentSniff::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'config' => [
|
||||||
|
ForbiddenPrivateMethods::class => [
|
||||||
|
'title' => 'The usage of private methods is not idiomatic in Laravel.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Requirements
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define a level you want to reach per `Insights` category.
|
||||||
|
| When a score is lower than the minimum level defined, then an error
|
||||||
|
| code will be returned. This is optional and individually defined.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'requirements' => [
|
||||||
|
// 'min-quality' => 0,
|
||||||
|
// 'min-complexity' => 0,
|
||||||
|
// 'min-architecture' => 0,
|
||||||
|
// 'min-style' => 0,
|
||||||
|
// 'disable-security-check' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
@ -164,7 +164,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'secure' => env('SESSION_SECURE_COOKIE', false),
|
'secure' => env('SESSION_SECURE_COOKIE', null),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -30,4 +30,4 @@ $factory->define(App\Product::class, function (Faker $faker) {
|
|||||||
return factory(App\User::class)->create()->id;
|
return factory(App\User::class)->create()->id;
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateUsersTable extends Migration
|
class CreateUsersTable extends Migration
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreatePasswordResetsTable extends Migration
|
class CreatePasswordResetsTable extends Migration
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateProductsTable extends Migration
|
class CreateProductsTable extends Migration
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateItemsTable extends Migration
|
class CreateItemsTable extends Migration
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class AddLocationToUsers extends Migration
|
class AddLocationToUsers extends Migration
|
||||||
{
|
{
|
||||||
|
36
database/migrations/2022_11_13_183613_create_jobs_table.php
Normal file
36
database/migrations/2022_11_13_183613_create_jobs_table.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('jobs', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('queue')->index();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->unsignedTinyInteger('attempts');
|
||||||
|
$table->unsignedInteger('reserved_at')->nullable();
|
||||||
|
$table->unsignedInteger('available_at');
|
||||||
|
$table->unsignedInteger('created_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('jobs');
|
||||||
|
}
|
||||||
|
};
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
|
2
deploy.sh
Normal file
2
deploy.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
git checkout production && git merge master && git checkout - && git push origin production && ssh -A contabo -t "cd /var/www/shareit.brunofontes.net; git fetch --all; git checkout --force production; git pull origin production --force; ~/composer.phar install -n --optimize-autoloader --no-dev; npm install"
|
@ -70,4 +70,4 @@ return [
|
|||||||
To be able to do that you just need to select the item.</p>
|
To be able to do that you just need to select the item.</p>
|
||||||
<p class="mb-4">When adding a Product, you can specify a webpage (this is optional).</p>',
|
<p class="mb-4">When adding a Product, you can specify a webpage (this is optional).</p>',
|
||||||
|
|
||||||
];
|
];
|
@ -9,4 +9,4 @@ return [
|
|||||||
'cancel_alert' => 'Cancel Alert',
|
'cancel_alert' => 'Cancel Alert',
|
||||||
'alert_me' => 'Alert me',
|
'alert_me' => 'Alert me',
|
||||||
'take' => 'Take It'
|
'take' => 'Take It'
|
||||||
];
|
];
|
@ -37,4 +37,4 @@ return [
|
|||||||
*/
|
*/
|
||||||
'back' => 'BACK',
|
'back' => 'BACK',
|
||||||
|
|
||||||
];
|
];
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Strings from the product pages
|
* Strings from the product pages
|
||||||
* They are separeted by the file that calls them.
|
* They are separeted by the file that calls them.
|
||||||
* Sometimes, a string is used on another file,
|
* Sometimes, a string is used on another file,
|
||||||
* so it will stay at the common segment.
|
* so it will stay at the common segment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ return [
|
|||||||
'100yearsSolitude' => 'One Hundred Years of Solitude',
|
'100yearsSolitude' => 'One Hundred Years of Solitude',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addProductForm.blade.php
|
* addProductForm.blade.php
|
||||||
*/
|
*/
|
||||||
'name' => 'Name:',
|
'name' => 'Name:',
|
||||||
'book' => 'Book',
|
'book' => 'Book',
|
||||||
@ -60,4 +60,4 @@ return [
|
|||||||
'noItemsYet' => 'There are no items yet. Include one with the form above.',
|
'noItemsYet' => 'There are no items yet. Include one with the form above.',
|
||||||
'addItem' => 'Add item',
|
'addItem' => 'Add item',
|
||||||
'back' => 'BACK',
|
'back' => 'BACK',
|
||||||
];
|
];
|
15
lang/en/test.php
Normal file
15
lang/en/test.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used during authentication for various
|
||||||
|
| messages that we need to display to the user. You are free to modify
|
||||||
|
| these language lines according to your application's requirements.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'failed' => 'These credentials do not match our records.',
|
||||||
|
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||||
|
];
|
@ -7,4 +7,4 @@ return [
|
|||||||
'Help' => 'Help',
|
'Help' => 'Help',
|
||||||
'copyright' => '© 2018 Bruno Fontes All Rights Reserved',
|
'copyright' => '© 2018 Bruno Fontes All Rights Reserved',
|
||||||
'byAuthor' => 'By Bruno Fontes',
|
'byAuthor' => 'By Bruno Fontes',
|
||||||
];
|
];
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
":itemname is available!": ":itemname está disponível!",
|
":itemname is available!": ":itemname está disponível!",
|
||||||
"Hi, :username,": "Olá, :username,",
|
"Hi, :username,": "Olá, :username,",
|
||||||
"Good news: :itemname is available!": "Uma boa notícia: :itemname está disponível!",
|
"Good news: :itemname is available!": "Boa notícia: :itemname está disponível!",
|
||||||
"The item <em>:itemname (:productname)</em> is now available on **Share It**.": "O item <em>:itemname (:productname)</em> já está disponível no **Share It**.",
|
"The item <em>:itemname (:productname)</em> is now available on **Share It**.": "O item <em>:itemname (:productname)</em> já está disponível no **Share It**.",
|
||||||
"**Take It** before anyone else at the website:": "Entre no nosso site para usar o item antes de todo mundo.",
|
"**Take It** before anyone else at the website:": "Entre no nosso site para usar o item antes de todo mundo.",
|
||||||
|
|
||||||
@ -46,5 +46,7 @@
|
|||||||
|
|
||||||
"The item doesn't exist.": "O item não existe.",
|
"The item doesn't exist.": "O item não existe.",
|
||||||
"The product doesn't exist or doesn't belongs to you.": "O produto não existe ou não é seu.",
|
"The product doesn't exist or doesn't belongs to you.": "O produto não existe ou não é seu.",
|
||||||
"This item is already taken": "Esse item já está sendo usado"
|
"This item is already taken": "Esse item já está sendo usado.",
|
||||||
|
"You cannot return an item that is not with you": "Você não pode devolver um item que não está com você.",
|
||||||
|
"Oh! This item has just being returned. Take it before anyone else!": "Opa! Esse item acabou de ser devolvido. Aproveite!"
|
||||||
}
|
}
|
@ -71,4 +71,4 @@ return [
|
|||||||
Para fazer isso, você só precisa clicar no item que deseja compartilhar e incluir outras pessoas.</p>
|
Para fazer isso, você só precisa clicar no item que deseja compartilhar e incluir outras pessoas.</p>
|
||||||
<p class="mb-4">Ao adicionar um produto, você pode especificar um site (opcional).</p>',
|
<p class="mb-4">Ao adicionar um produto, você pode especificar um site (opcional).</p>',
|
||||||
|
|
||||||
];
|
];
|
@ -9,4 +9,4 @@ return [
|
|||||||
'cancel_alert' => 'Cancelar alerta',
|
'cancel_alert' => 'Cancelar alerta',
|
||||||
'alert_me' => 'Alertar',
|
'alert_me' => 'Alertar',
|
||||||
'take' => 'Usar'
|
'take' => 'Usar'
|
||||||
];
|
];
|
@ -36,4 +36,4 @@ return [
|
|||||||
* String from item.blade.php
|
* String from item.blade.php
|
||||||
*/
|
*/
|
||||||
'back' => 'VOLTAR',
|
'back' => 'VOLTAR',
|
||||||
];
|
];
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Strings from the product pages
|
* Strings from the product pages
|
||||||
* They are separeted by the file that calls them.
|
* They are separeted by the file that calls them.
|
||||||
* Sometimes, a string is used on another file,
|
* Sometimes, a string is used on another file,
|
||||||
* so it will stay at the common segment.
|
* so it will stay at the common segment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ return [
|
|||||||
'100yearsSolitude' => 'Cem anos de solidão',
|
'100yearsSolitude' => 'Cem anos de solidão',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addProductForm.blade.php
|
* addProductForm.blade.php
|
||||||
*/
|
*/
|
||||||
'name' => 'Nome:',
|
'name' => 'Nome:',
|
||||||
'book' => 'Livro',
|
'book' => 'Livro',
|
||||||
@ -58,4 +58,4 @@ return [
|
|||||||
'noItemsYet' => 'Ainda não há itens cadastrados. Inclua um no formulário acima.',
|
'noItemsYet' => 'Ainda não há itens cadastrados. Inclua um no formulário acima.',
|
||||||
'addItem' => 'Incluir item',
|
'addItem' => 'Incluir item',
|
||||||
'back' => 'VOLTAR',
|
'back' => 'VOLTAR',
|
||||||
];
|
];
|
@ -7,4 +7,4 @@ return [
|
|||||||
'Help' => 'Ajuda',
|
'Help' => 'Ajuda',
|
||||||
'copyright' => '© 2018 Bruno Fontes Todos os direitos reservados',
|
'copyright' => '© 2018 Bruno Fontes Todos os direitos reservados',
|
||||||
'byAuthor' => 'Por Bruno Fontes',
|
'byAuthor' => 'Por Bruno Fontes',
|
||||||
];
|
];
|
0
public/favicon.ico → package-lock.json
generated
0
public/favicon.ico → package-lock.json
generated
34
package.json
34
package.json
@ -1,22 +1,26 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run development",
|
"dev": "vite",
|
||||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
"build": "vite build"
|
||||||
"watch": "npm run development -- --watch",
|
|
||||||
"watch-poll": "npm run watch -- --watch-poll",
|
|
||||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
|
||||||
"prod": "npm run production",
|
|
||||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "^0.18",
|
"axios": "^1.1.3",
|
||||||
"bootstrap": "^4.0.0",
|
"bootstrap": "^4.6.0",
|
||||||
"cross-env": "^5.1",
|
"cross-env": "^5.2.1",
|
||||||
"jquery": "^3.2",
|
"jquery": "^3.5.1",
|
||||||
"laravel-mix": "^2.0",
|
"laravel-echo": "^1.14.1",
|
||||||
"lodash": "^4.17.5",
|
"laravel-vite-plugin": "^0.7.0",
|
||||||
"popper.js": "^1.12",
|
"lodash": "^4.17.21",
|
||||||
"vue": "^2.5.7"
|
"popper.js": "^1.16.1",
|
||||||
|
"postcss": "^8.4.19",
|
||||||
|
"pusher-js": "^7.4.1",
|
||||||
|
"resolve-url-loader": "^3.1.3",
|
||||||
|
"sass": "^1.56.1",
|
||||||
|
"sass-loader": "^8.0.2",
|
||||||
|
"vite": "^3.2.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
phpstan.neon
Normal file
17
phpstan.neon
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
includes:
|
||||||
|
- ./vendor/nunomaduro/larastan/extension.neon
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
paths:
|
||||||
|
- app
|
||||||
|
|
||||||
|
# The level 8 is the highest level
|
||||||
|
level: 5
|
||||||
|
|
||||||
|
ignoreErrors:
|
||||||
|
- '#Unsafe usage of new static#'
|
||||||
|
|
||||||
|
excludePaths:
|
||||||
|
- ./*/*/FileToBeExcluded.php
|
||||||
|
|
||||||
|
checkMissingIterableValueType: false
|
48
public/build/assets/app.4993c47e.js
vendored
Normal file
48
public/build/assets/app.4993c47e.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/build/assets/pusher.a7756fcc.js
vendored
Normal file
1
public/build/assets/pusher.a7756fcc.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import"https://js.pusher.com/7.2/pusher.min.js";var n=new Pusher("93b3e504421787295454",{cluster:"us2"}),o=n.subscribe("touchedItem");o.bind("RefreshPage",function(e){window.location.reload(),console.log(JSON.stringify(e))});
|
12
public/build/manifest.json
Normal file
12
public/build/manifest.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"resources/js/app.js": {
|
||||||
|
"file": "assets/app.4993c47e.js",
|
||||||
|
"src": "resources/js/app.js",
|
||||||
|
"isEntry": true
|
||||||
|
},
|
||||||
|
"resources/js/pusher.js": {
|
||||||
|
"file": "assets/pusher.a7756fcc.js",
|
||||||
|
"src": "resources/js/pusher.js",
|
||||||
|
"isEntry": true
|
||||||
|
}
|
||||||
|
}
|
9254
public/css/app.css
vendored
9254
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
46233
public/js/app.js
vendored
46233
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
77
public/js/app.js.LICENSE.txt
Normal file
77
public/js/app.js.LICENSE.txt
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*!
|
||||||
|
* Bootstrap v4.5.2 (https://getbootstrap.com/)
|
||||||
|
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||||
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Determine if an object is a Buffer
|
||||||
|
*
|
||||||
|
* @author Feross Aboukhadijeh <https://feross.org>
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sizzle CSS Selector Engine v2.3.5
|
||||||
|
* https://sizzlejs.com/
|
||||||
|
*
|
||||||
|
* Copyright JS Foundation and other contributors
|
||||||
|
* Released under the MIT license
|
||||||
|
* https://js.foundation/
|
||||||
|
*
|
||||||
|
* Date: 2020-03-14
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Vue.js v2.6.12
|
||||||
|
* (c) 2014-2020 Evan You
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* jQuery JavaScript Library v3.5.1
|
||||||
|
* https://jquery.com/
|
||||||
|
*
|
||||||
|
* Includes Sizzle.js
|
||||||
|
* https://sizzlejs.com/
|
||||||
|
*
|
||||||
|
* Copyright JS Foundation and other contributors
|
||||||
|
* Released under the MIT license
|
||||||
|
* https://jquery.org/license
|
||||||
|
*
|
||||||
|
* Date: 2020-05-04T22:49Z
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Lodash <https://lodash.com/>
|
||||||
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||||
|
* Released under MIT license <https://lodash.com/license>
|
||||||
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||||
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**!
|
||||||
|
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
||||||
|
* @version 1.16.1
|
||||||
|
* @license
|
||||||
|
* Copyright (c) 2016 Federico Zivolo and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
1
public/mix-manifest.json
Normal file
1
public/mix-manifest.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
62
resources/js/app.js
vendored
62
resources/js/app.js
vendored
@ -5,9 +5,10 @@
|
|||||||
* building robust, powerful web applications using Vue and Laravel.
|
* building robust, powerful web applications using Vue and Laravel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('./bootstrap');
|
import './bootstrap';
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
window.Vue = require('vue');
|
// window.Vue = require('vue');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next, we will create a fresh Vue application instance and attach it to
|
* Next, we will create a fresh Vue application instance and attach it to
|
||||||
@ -15,8 +16,59 @@ window.Vue = require('vue');
|
|||||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
// Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
||||||
|
|
||||||
const app = new Vue({
|
// const app = new Vue({
|
||||||
el: '#app'
|
// el: '#app'
|
||||||
|
// });
|
||||||
|
|
||||||
|
function updateTime() {
|
||||||
|
var dates = document.getElementsByClassName("takenItemDate");
|
||||||
|
for (let i = 0; i < dates.length; i++) {
|
||||||
|
let time = dates.item(i).innerText;
|
||||||
|
let fromNow = moment(time).fromNow();
|
||||||
|
let id = "itemPassedTime_" + dates.item(i).id;
|
||||||
|
document.getElementById(id).innerText = fromNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateTime();
|
||||||
|
setInterval(updateTime, 1 * 60 * 1000);
|
||||||
|
|
||||||
|
|
||||||
|
function setFaviconNumber(number) {
|
||||||
|
var canvas = document.createElement('canvas'),
|
||||||
|
ctx,
|
||||||
|
img = document.createElement('img'),
|
||||||
|
link = document.getElementById('favicon').cloneNode(true);
|
||||||
|
|
||||||
|
if (canvas.getContext) {
|
||||||
|
canvas.height = canvas.width = 48; // set the size
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
img.onload = function () { // once the image has loaded
|
||||||
|
ctx.drawImage(this, 0, 0);
|
||||||
|
ctx.font = 'bold 35px "helvetica", sans-serif';
|
||||||
|
ctx.fillStyle = '#ffff66';
|
||||||
|
ctx.fillText(number, 3, 25);
|
||||||
|
link.href = canvas.toDataURL('image/png');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
};
|
||||||
|
img.src = 'favicon.png';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
usedItems = document.getElementById("usedItems").innerText;
|
||||||
|
setFaviconNumber(usedItems);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source:
|
||||||
|
* https://www.designcise.com/web/tutorial/how-to-detect-if-the-browser-tab-is-active-or-not-using-javascript
|
||||||
|
*/
|
||||||
|
document.addEventListener('visibilitychange', function (event) {
|
||||||
|
if (document.hidden) {
|
||||||
|
console.log('not visible');
|
||||||
|
} else {
|
||||||
|
updateTime();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
54
resources/js/bootstrap.js
vendored
54
resources/js/bootstrap.js
vendored
@ -1,18 +1,5 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
window._ = require('lodash');
|
window._ = _;
|
||||||
window.Popper = require('popper.js').default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
|
|
||||||
* for JavaScript based Bootstrap features such as modals and tabs. This
|
|
||||||
* code may be modified to fit the specific needs of your application.
|
|
||||||
*/
|
|
||||||
|
|
||||||
try {
|
|
||||||
window.$ = window.jQuery = require('jquery');
|
|
||||||
|
|
||||||
require('bootstrap');
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||||
@ -20,37 +7,28 @@ try {
|
|||||||
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.axios = require('axios');
|
import axios from 'axios';
|
||||||
|
window.axios = axios;
|
||||||
|
|
||||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
|
||||||
/**
|
|
||||||
* Next we will register the CSRF Token as a common header with Axios so that
|
|
||||||
* all outgoing HTTP requests automatically have it attached. This is just
|
|
||||||
* a simple convenience so we don't have to attach every token manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
let token = document.head.querySelector('meta[name="csrf-token"]');
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
|
||||||
} else {
|
|
||||||
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Echo exposes an expressive API for subscribing to channels and listening
|
* Echo exposes an expressive API for subscribing to channels and listening
|
||||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||||
* allows your team to easily build robust real-time web applications.
|
* allows your team to easily build robust real-time web applications.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// import Echo from 'laravel-echo'
|
import Echo from 'laravel-echo';
|
||||||
|
|
||||||
// window.Pusher = require('pusher-js');
|
import Pusher from 'pusher-js';
|
||||||
|
window.Pusher = Pusher;
|
||||||
|
|
||||||
// window.Echo = new Echo({
|
window.Echo = new Echo({
|
||||||
// broadcaster: 'pusher',
|
broadcaster: 'pusher',
|
||||||
// key: process.env.MIX_PUSHER_APP_KEY,
|
key: import.meta.env.VITE_PUSHER_APP_KEY,
|
||||||
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
|
wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
|
||||||
// encrypted: true
|
wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
|
||||||
// });
|
wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
|
||||||
|
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
|
||||||
|
enabledTransports: ['ws', 'wss'],
|
||||||
|
});
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-header">Example Component</div>
|
|
||||||
|
|
||||||
<div class="card-body">
|
|
||||||
I'm an example component.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
mounted() {
|
|
||||||
console.log('Component mounted.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
10
resources/js/pusher.js
vendored
Normal file
10
resources/js/pusher.js
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import 'https://js.pusher.com/7.2/pusher.min.js';
|
||||||
|
var pusher = new Pusher('93b3e504421787295454', {
|
||||||
|
cluster: 'us2'
|
||||||
|
});
|
||||||
|
|
||||||
|
var channel = pusher.subscribe('touchedItem');
|
||||||
|
channel.bind('RefreshPage', function(data) {
|
||||||
|
window.location.reload();
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
});
|
@ -14,8 +14,10 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<form class="d-inline" method="POST" action="{{ route('verification.resend') }}">
|
||||||
|
@csrf
|
||||||
{{ __('Before proceeding, please check your email for a verification link.') }}
|
{{ __('Before proceeding, please check your email for a verification link.') }}
|
||||||
{{ __('If you did not receive the email') }}, <a href="{{ route('verification.resend') }}">{{ __('click here to request another') }}</a>.
|
{{ __('If you did not receive the email') }}, <button type="submit" class="btn btn-link p-0 m-0 align-baseline">{{ __('click here to request another') }}</button>.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<script type="text/javascript">
|
@vite('resources/js/pusher.js')
|
||||||
setInterval(function() {
|
|
||||||
window.location.reload(true);
|
|
||||||
}, 2*60000); //NOTE: period is passed in milliseconds
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
@ -49,4 +45,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
@if ($item->used_by == \Auth::id())
|
@if ($item->used_by == \Auth::id())
|
||||||
<form action="/take" method="POST" class="form-inline">
|
<form action="/take" method="POST" class="form-inline">
|
||||||
<em class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em>
|
<em id="itemPassedTime_{{$item->id}}" class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em>
|
||||||
|
<div hidden class="takenItemDate" id="{{$item->id}}">{{\Carbon\Carbon::parse($item->updated_at)->format('Y-m-d\TH:i:s.uP')}}</div>
|
||||||
<div class="w-100 d-xm-block d-sm-none"></div>
|
<div class="w-100 d-xm-block d-sm-none"></div>
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
@ -16,8 +17,9 @@
|
|||||||
@if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id())
|
@if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id())
|
||||||
<strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong>
|
<strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong>
|
||||||
@endif
|
@endif
|
||||||
<small>({{$item->updated_at->diffForHumans()}})</small>
|
<small id="itemPassedTime_{{$item->id}}">({{$item->updated_at->diffForHumans()}})</small>
|
||||||
</em>
|
</em>
|
||||||
|
<div hidden class="takenItemDate" id="{{$item->id}}">{{$item->updated_at->format('Y-m-d\TH:i:s.uP')}}</div>
|
||||||
<div class="w-100 d-xm-block d-sm-none"></div>
|
<div class="w-100 d-xm-block d-sm-none"></div>
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
<input type="hidden" name="item" value="{{$item->id}}">
|
<input type="hidden" name="item" value="{{$item->id}}">
|
||||||
@ -28,4 +30,4 @@
|
|||||||
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">@lang('home.alert_me')</button>
|
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">@lang('home.alert_me')</button>
|
||||||
@endif
|
@endif
|
||||||
</form>
|
</form>
|
||||||
@endif
|
@endif
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<title>{{ config('app.name', 'Laravel') }} {{ isset($usedItems) && $usedItems > 0 ? "(${usedItems})" : '' }}</title>
|
<title>{{ config('app.name', 'Laravel') }} {{ isset($usedItems) && $usedItems > 0 ? "(${usedItems})" : '' }}</title>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
@vite('resources/js/app.js')
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
|
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
|
||||||
@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
<!-- Styles -->
|
<!-- Styles -->
|
||||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
|
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div hidden id="usedItems">{{ isset($usedItems) && $usedItems > 0 ? $usedItems : '' }}</div>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
|
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -88,4 +91,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,4 +16,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- Copyright -->
|
<!-- Copyright -->
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
@include('layouts.tracker')
|
3
resources/views/layouts/tracker.blade.php
Normal file
3
resources/views/layouts/tracker.blade.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
var owa_baseUrl='https://brunofontes.net/owa/';var owa_cmds=owa_cmds||[];owa_cmds.push(['setSiteId','15a38975230dfe7528d647a1419be7f7']);owa_cmds.push(['trackPageView']);owa_cmds.push(['trackClicks']);owa_cmds.push(['trackDomStream']);(function(){var _owa=document.createElement('script');_owa.type='text/javascript';_owa.async=true;owa_baseUrl=('https:'==document.location.protocol?window.owa_baseSecUrl||owa_baseUrl.replace(/http:/,'https:'):owa_baseUrl);_owa.src=owa_baseUrl+'modules/base/js/owa.tracker-combined-min.js';var _owa_s=document.getElementsByTagName('script')[0];_owa_s.parentNode.insertBefore(_owa,_owa_s)}());
|
||||||
|
</script>
|
@ -5,6 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Share It</title>
|
<title>Share It</title>
|
||||||
|
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css">
|
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css">
|
||||||
@ -114,5 +115,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@include('layouts.tracker')
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -14,3 +14,8 @@
|
|||||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||||
return (int) $user->id === (int) $id;
|
return (int) $user->id === (int) $id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Broadcast::channel('touchedItem', function ($user) {
|
||||||
|
return true;
|
||||||
|
/* return $user->id === Item::findOrNew($itemId)->users->find($user->id)->id; */
|
||||||
|
});
|
||||||
|
2
ssh_homestead.sh
Normal file
2
ssh_homestead.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
echo "Homestead password is: vagrant"
|
||||||
|
ssh homestead -t "cd shareit; bash --login"
|
7
start_vagrant.sh
Normal file
7
start_vagrant.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
export VAGRANT_CWD=/home/bruno/development/Homestead/
|
||||||
|
vagrant up
|
||||||
|
eval $DEV_BROWSER http://shareit.test \
|
||||||
|
https://mailtrap.io/inboxes/455614/messages \
|
||||||
|
https://dashboard.pusher.com/apps/1505830/console \
|
||||||
|
&
|
@ -3,8 +3,8 @@
|
|||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use \App\Product;
|
use \App\Product;
|
||||||
use Tests\TestCase;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
1
updateCompserNPM.sh
Normal file
1
updateCompserNPM.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
ssh homestead -t 'cd shareit; /usr/local/bin/composer update; npm update; echo; echo -n "Press enter to exit..."; read'
|
28
vite.config.js
vendored
Normal file
28
vite.config.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import laravel from 'laravel-vite-plugin';
|
||||||
|
// import react from '@vitejs/plugin-react';
|
||||||
|
// import vue from '@vitejs/plugin-vue';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
laravel([
|
||||||
|
// 'resources/css/app.css',
|
||||||
|
'resources/js/app.js',
|
||||||
|
'resources/js/pusher.js',
|
||||||
|
]),
|
||||||
|
// react(),
|
||||||
|
// vue({
|
||||||
|
// template: {
|
||||||
|
// transformAssetUrls: {
|
||||||
|
// base: null,
|
||||||
|
// includeAbsolute: false,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': '/resources/js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
15
webpack.mix.js
vendored
15
webpack.mix.js
vendored
@ -1,15 +0,0 @@
|
|||||||
const mix = require('laravel-mix');
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Mix Asset Management
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Mix provides a clean, fluent API for defining some Webpack build steps
|
|
||||||
| for your Laravel application. By default, we are compiling the Sass
|
|
||||||
| file for the application as well as bundling up all the JS files.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
mix.js('resources/js/app.js', 'public/js')
|
|
||||||
.sass('resources/sass/app.scss', 'public/css');
|
|
Loading…
Reference in New Issue
Block a user