Tenho uma abela de usuarios e uma tabela de administradores e clientes.
Gostaria de uma ajuda para implementar um cadastro
users -> name, login, passord (pronta)
admins -> user_id, registratiom, etc..
client -> user_id, registratiom, etc...
Queria ajuda para extender de user as classes Admin e Client
Olhem como estáAdmin
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Admin extends User
{
use HasFactory;
protected $fillable = [
'name',
'email',
'password',
'registration'
];
private string $registration;
public function create(
string $name,
string $email,
string $password,
string $registration
)
{
//parent::create(['name'=>$name, 'email'=>$email, 'password'=>$password]);
parent::$name = $name;
parent::$email = $email;
parent::$password = $password;
$this->registration = $registration;
}
}
User
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
static string $name;
static string $email;
static string $password;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
public function roles() : BelongsToMany {
return $this->belongsToMany(Role::class);
}
public function hasHole(Array $roleName): bool
{
foreach ($this->roles as $role) {
if ($role->name === $roleName) {
return true;
}
}
return false;
}
public function hasHoles(Array $rolesName): bool
{
foreach ($this->roles as $role) {
foreach ($rolesName as $rolee) {
if ($role->name === $rolee) {
return true;
}
}
}
return false;
}
public function hasAbility(string $ability): bool
{
foreach ($this->roles as $role) {
if ($role->abilities->contains('name', $ability)) {
return true;
}
}
return false;
}
}
Como gravar um Admin na tabela admins sendo que ele é um User por extensão?
Tentei assim mas é claro que está errado...
public function store(Request $request, Admin $adminModel) {
$dados = $request->validate([
"name" => "required",
"email" => "required|email",
"password" => "required",
"registration" => "required"
]);
$dados["password"] = Hash::make($dados["password"]);
$admin = Admin::where("registration", $dados["registration"])->first();
if ($admin)
return
redirect()->route("admin.new")
->withErrors([
'fail' => 'Administrador já cadastrados<br>, favor verificar!'
]);
$newAdmin = $adminModel->create(
$dados['name'],
$dados['email'],
$dados['password'],
$dados['registration']
);
dd($newAdmin);
$adminModel->save();
//$adminModel::create($admin);
return redirect()->route("admin.new")->with("success",'Cadastrado com sucesso');
}
Gostaria de tirar uma dúvida com os amigos, referente a PDV.
Estou escrevendo um Sistema com Ponto de Vendas, a minha dúvida é o seguinte, referente ao procedimento mais correto.
Conforme o caixa vai efetuando a venda, o Sistema de PDV já realiza:
a baixa direto dos produtos no estoque
ou
somente após concretizar a venda o sistema baixa os produtos do estoque ?
Estou com uma pequena dúvida referente a Teclas de Atalho.
Quando o Caps Lock está ativado o Comando da Tecla de Atalho não funciona.
ou seja:
se estiver para letra minúscula ====> funciona
se estiver para letra maiúscula ====> não funciona
Como consigo evitar essa falha, tanto para Letra Maiúscula quanto Minúscula ?
o Código está assim:
document.addEventListener( 'keydown', evt => {
if (!evt.ctrlKey || evt.key !== 'r' )
return;// Não é Ctrl+r, portanto interrompemos o script
evt.preventDefault();
});
Grato,
Estou com a seguinte dúvida:
--> como faço para para implementar o input código do produto, para quando o usuário digitar o ID o sistema espera de 1s a 2s, sem ter que pressionar a tecla ENTER.
Olá pessoal, sou novo por aqui e estou precisando da ajuda de vcs!
Tenho um modulo de marketplace (webkul) e preciso alterar a quantidade de exibição de anunciantes de 4 para 20 por página.
Alguem poderia me ajuda? :)
Minha página de anuncinates é: https://lenda360.com.br/marketplace/seller/sellerlist/
Meu arquivo sellerlist contem:
<?php
/**
* Webkul Software.
*
* @category Webkul
* @package Webkul_Marketplace
* @author Webkul
* @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
* @license https://store.webkul.com/license.html
*/
$helper = $this->helper(\Webkul\Marketplace\Helper\Data::class);
$banner_display = $helper->getDisplayBanner();
$banner_image = $helper->getBannerImage();
$banner_content = $helper->getBannerContent();
$marketplacebutton = $helper->getMarketplacebutton();
$sellerlist_top_label = $helper->getSellerlisttopLabel();
$sellerlist_bottom_label = ($helper->getSellerlistbottomLabel());
$paramData = $this->getRequest()->getParams();
if (!isset($paramData['shop'])) {
$paramData['shop'] = '';
}
$sellerAccountUrl = $block->getUrl(
'marketplace/account/becomeseller',
["_secure" => $this->getRequest()->isSecure()]
);
if (!$helper->isCustomerLoggedIn()) {
$sellerAccountUrl = $block->getUrl(
'customer/account/create',
["_secure" => $this->getRequest()->isSecure()]
);
}
?>
<div class="wk-mp-design wk-mp-landingpage">
<?php
if ($banner_display) {?>
<div class="wk-mp-banner-container">
<div class="wk-mp-banner">
<div class="wk-mp-header">
<h1><?= $block->escapeHtml($marketplacebutton); ?></h1>
<h2>
<?= /* @noEscape */ $block->getCmsFilterContent($banner_content)?>
</h2>
<p>
<a href="<?= $block->escapeUrl($block->getUrl('marketplace/account/becomeseller/', ['_secure' => $this->getRequest()->isSecure()])); ?>">
<button class="button wk-mp-landing-button">
<span>
<span>
<strong><?= $block->escapeHtml($marketplacebutton); ?></strong>
</span>
</span>
</button>
</a>
</p>
</div>
</div>
</div>
<?php
} ?>
<h1 class="wk-marketplace-label"><?= $block->escapeHtml($sellerlist_top_label) ?></h1>
<style>
</style>
<div clas="wk-srach-wrapper">
<form method="get" action="<?= $block->escapeUrl($block->getUrl('marketplace/seller/sellerlist', ['_secure' => $this->getRequest()->isSecure()]))?>" id="search_mini_form" class="wk-search no-p" style="">
<div class="control">
<input id="sellersearch" type="search" name="shop" value="<?= $block->escapeHtml($paramData['shop'])?>" class="input-text required-entry" maxlength="128" placeholder="<?= $block->escapeHtml(__('Search sellers by shop name from here'))?>..." autocomplete="off" style="width:100%;border:1px solid #ccc;float:left;">
<button type="submit" title="Search" class="button"><span class="span"><span><?= $block->escapeHtml(__('Search')) ?></span></span></button>
</div>
</form>
</div>
<div class="wk-mp-sellerlist-container" style="display:inline-block;padding: 0;padding-top: 20px;width: 100%;">
<?php
if (count($block->getSellerCollection())==0) { ?>
<div class="wk-emptymsg">
<?= $block->escapeHtml(__('No Seller Available')) ?>
</div>
<?php
} else {?>
<ul>
<?php
foreach ($block->getSellerCollection() as $seller_coll) {
$seller_id = $seller_coll->getSellerId();
$seller_product_count = 0;
$profileurl = $seller_coll->getShopUrl();
$shoptitle = '';
$logo="noimage.png";
$seller_product_count = $helper->getSellerProCount($seller_id);
$shoptitle = $seller_coll->getShopTitle();
$logo=$seller_coll->getLogoPic()==''?"noimage.png":$seller_coll->getLogoPic();
if (!$shoptitle) {
$shoptitle = $profileurl;
}
$logo=$helper->getMediaUrl().'avatar/'.$logo;
?>
<li>
<div class="wk-mp-sellerlist-wrap">
<div class="wk-sellerlist-divide1">
<a href="<?= $block->escapeUrl($helper->getRewriteUrl('marketplace/seller/profile/shop/'.$profileurl));?>" title="<?= $block->escapeHtml(__("View Seller's Shop")) ?>"><img src="<?= $block->escapeUrl($logo) ?>"></a>
</div>
<div class="wk-sellerlist-divide2">
<div>
<a href="<?= $block->escapeUrl($helper->getRewriteUrl('marketplace/seller/profile/shop/'.$profileurl));?>" title="<?= $block->escapeHtml(__("View Seller's Shop")) ?>">
<strong><?= $block->escapeHtml($shoptitle) ?></strong>
</a>
</div>
<div><?= $block->escapeHtml(__('%1 Total Products', $seller_product_count)) ?></div>
<a href="<?= $block->escapeUrl($helper->getRewriteUrl('marketplace/seller/collection/shop/'.$profileurl));?>">
<button class="button" title="<?= $block->escapeHtml(__("View Seller's Collection")) ?>">
<span>
<span>
<?= $block->escapeHtml(__('View All')); ?>
</span>
</span>
</button>
</a>
</div>
</div>
</li>
<?php
}?>
</ul>
<?php
}?>
</div>
<?php if ($block->getPagerHtml()): ?>
<div class="order-products-toolbar toolbar bottom"><?= $block->getPagerHtml(); ?></div>
<?php endif ?>
<h1 class="wk-marketplace-label"><?= /* @noEscape */ $sellerlist_bottom_label ?></h1>
<a href="<?= $block->escapeUrl($sellerAccountUrl)?>">
<button class="button wk-mp-landing-button">
<span>
<span>
<strong><?= $block->escapeHtml($marketplacebutton); ?></strong>
</span>
</span>
</button>
</a>
</div>
<script>
require([
"jquery",
"mage/mage",
], function($){
$('.page-title-wrapper').hide();
$('.wk-mp-banner').css('background-image','url("<?= $block->escapeUrl($banner_image) ?>")');
});
</script>
Compartilhar este post
Link para o post
Compartilhar em outros sites