在多供应商网站上工作。当商店/供应商用户想登录时突然得到这个错误没有问题普通用户这里有两种类型用户一种是供应商或商店老板/另一种普通客户当供应商想登录时得到这个错误。但正常用户没有问题面临的登录。添加新列,但问题是继续SQL完整性错误。
Query: (SQL: select * from `shops` where `user_shops` = 233 limit 1)
这是登录控制器。
登录控制器的详细信息
public function userlogin(Request $request){
$data = Cart::getContent();
$this->validate($request, [
'email' => 'required',
'password' => 'required',
],[
'email.required' => 'Email not matched with Database!',
'password.required' => 'Password not matched with Database!',
]);
$checkUserInput = filter_var($request->input('email'), FILTER_VALIDATE_EMAIL)?'email': 'username';
$user = Auth::guard('web')->attempt([$checkUserInput => $request->email,'password'=>$request->password]);
if($user == 'true'){
if(Auth::user()->is_activated == 1){
if(count($data)>0){
if(count(Cart::session(Auth::user()->id)->getContent())>0){
foreach ($data as $key => $value) {
if(!Cart::session(Auth::user()->id)->get($value->id) ){
Cart::session(Auth::user()->id)->add($value->id, $value->name,$value->price,$value->quantity, $value->image,array('color' => $value->attributes->color));
}else{
Cart::session(Auth::user()->id)->update($value->id, array(
'quantity' => array(
'relative' => false,
'value' => $request->quantity
),
'attributes' => array(
'color' => $value->attributes->color
),
));
}
}
}else{
foreach ($data as $key => $value) {
Cart::session(Auth::user()->id)->add($value->id, $value->name,$value->price,$value->quantity, $value->image,array('color' => $value->attributes->color));
}
}
}
if(Auth::user()->user_type == 2){
$model = Shop::where('user_id',Auth::user()->$user_id)->first();
if($model){
if($request->previous){
return redirect()->route('neneMart.dashboard');
}else{
return Redirect::to($request->previous);
}
}else{
if(empty($request->previous)){
return redirect()->route('create-shop');
}else{
return Redirect::to($request->previous);
}
}
}else{
if(empty($request->previous)){
return redirect()->route('home');
}else{
return Redirect::to($request->previous);
}
}
}
else{
return redirect()->route('user-login')->with(Auth::logout())->with('error', 'User email has not been activated yet!');
}
}else{
return redirect()->route('user-login')->with('error', 'Whoops! Wrong Email or Username or Password !');
}
}`
路线
Route:: get('user-login', 'Auth\LoginController@usershowLoginForm')->name('user-login');
Route:: post('userLogin', 'Auth\LoginController@userlogin')->name('userLogin');
车间管理控制员
public function index()
{
$shop = Shop::where('user_id',Auth::user()->id)->first();
$model = ShopManagement::where('shop_id','Nenemart-'.$shop->id)->first();
$shopid = 'Nenemart-'.$shop->id;
$agent = new Agent();
if($agent->isMobile() || $agent->isTablet()){
return view('mobile.mart.shopmanagemnt',compact('model','shopid'));
}else{
return view('frontend.mart.shopmanagemnt',compact('model','shopid'));
}
}
public function vendorShop(){
$shop = Shop::where('user_id',Auth::user()->id)->first();
$model = ShopManagement::where('shop_id','Nenemart-'.$shop->id)->first();
$vendorProducts = Product::orderBy('id', 'dese')->where('created_by', $shop->id)->where('type', 1)->get();
$agent = new Agent();
if($agent->isMobile() || $agent->isTablet()){
return view('mobile.mart.vendorShop',compact('model', 'vendorProducts'));
}else{
return view('frontend.mart.vendorShop',compact('model', 'vendorProducts'));
}
}
商店管理模式
protected $table = 'shop_management';
protected $primaryKey = 'id';
public static function getImage($shop_id){
$model = Self::where('shop_id','Nenemart-'.$shop_id)->first();
if($model){
return $model->shop_logo;
}else{
return '';
}
}
}
**店铺模型**
<?php
namespace App\Model\Frontend;
use Illuminate\Database\Eloquent\Model;
use Session;
use App\Model\Product;
use App\Model\MobileColor;
use App\Http\Controllers\HomeController;
use Auth;
use DB;
class Shop extends Model
{
protected $fillable = [
'user_id', 'shop_name', 'complex_name', 'brand_category_id', 'shop_mobile', 'shop_phone', 'trade_license', 'address', 'city', 'zipcode', 'opening_day', 'opening_time', 'closing_time'
];
public static function checkShopIsVerified($user_id){
$model = Self::where('user_id',$user_id)->where('status',1)->first();
if($model){
return true;
}else{
return false;
}
}
public static function getTodayOrder(){
$shop = Shop::where('user_id',Auth::user()->id)->first();
if($shop){
$data = DB::select("SELECT po.*, pod.id as pod_id,pod.product_id,pod.color_id,pod.quantity,pod.price,pod.status as p_status,p.product_code,p.model,p.type FROM product_order as po RIGHT JOIN product_order_details as pod ON po.id = pod.order_id JOIN products as p on p.id = pod.product_id WHERE p.created_by = ".$shop->id." and p.type = 1 and pod.status = 0 and po.date=".date('Y-m-d')." order by po.id desc");
$array = Self::processData($data);
}else{
$array = array();
}
return sizeof($array);
}
public static function getTotalCompleteOrder(){
$shop = Shop::where('user_id',Auth::user()->id)->first();
if($shop){
$data = DB::select("SELECT po.*, pod.id as pod_id,pod.product_id,pod.color_id,pod.quantity,pod.price,pod.status as p_status,p.product_code,p.model,p.type FROM product_order as po RIGHT JOIN product_order_details as pod ON po.id = pod.order_id JOIN products as p on p.id = pod.product_id WHERE p.created_by = ".$shop->id." and p.type = 1 and pod.status = 1 order by po.id desc");
$array = Self::processData($data);
}else{
$array = array();
}
return sizeof($array);
}
public static function getTotalPendingOrder(){
$data = DB::select("SELECT po.*, pod.id as pod_id,pod.product_id,pod.color_id,pod.quantity,pod.price,pod.status as p_status,p.product_code,p.model,p.type FROM product_order as po RIGHT JOIN product_order_details as pod ON po.id = pod.order_id JOIN products as p on p.id = pod.product_id WHERE p.type = 1 and pod.status = 0 order by po.id desc");
$array = Self::processData($data);
return sizeof($array);
}
public static function getmonthlySale(){
$first_day_this_month = date('Y-m-01'); // hard-coded '01' for first day
$last_day_this_month = date('Y-m-t');
$total = 0;
$shop = Shop::where('user_id',Auth::user()->id)->first();
if($shop){
$data = DB::select("SELECT pod.quantity*pod.price as total FROM product_order as po RIGHT JOIN product_order_details as pod ON po.id = pod.order_id JOIN products as p on p.id = pod.product_id WHERE p.created_by = ".$shop->id." and p.type = 1 and pod.status = 1 and po.date between ".$first_day_this_month." and ".$last_day_this_month." order by po.id desc");
if(sizeof($data)>0){
foreach($data as $d){
$total +=$d->total;
}
}
}
return $total;
}
错误
此函数有问题。它应该返回使用下面的sql调用收集的数据的json字符串。问题是,当通过服务器访问页面时(例如-localhost/app/API/states/Alabama/1/10.json),我得到一个错误代码“500”。奇怪的是,数据在使用.json和不使用appending.json的情况下按预期显示。据我所知,控制器和模型设置得很好,但错误代码仍然存在: {“code”:500,“ur
关于,我正在使用主键=idusuarios的同一视图更新一个名为usuarios的表,insert使我完美地解决了问题,因为当我要更新时,它会生成错误 SQLSTATE[42S22]:找不到列: 1054未知列'usuarios.id'in'where子句'(SQL: Select*fromwhere. 这是我的密码 模型 类Usuario扩展模型{ 另一张表的模型 控制器 公理
我正在数据库雄辩的关系一对一,但写代码后,我得到一个错误: SQLSTATE[42S22]:未找到列:1054个未知列“posts”。在where子句中删除了“'in'”(SQL:) 此代码用于我链接用户id的post表 后表迁移 这是我要链接帖子的用户表 用户模型迁移 User.php代码 这是路线: Routes\web.php
当我想更新数据,和laravel仍然显示列ID,但我不使用列ID在我的数据库,我已经改变了控制器 这是我的移民局 这是我的模型 这是我的控制器,没有任何请求或存储来'id' 这是视图editbarang.blade.php 我得到了这样的错误 SQLSTATE[42S22]:未找到列:1054“where子句”中的未知列“id”(SQL:updateset=Barang 02,=2019-06-2
错误:java.SQL.sqlsyntaxerrorexception:您的SQL语法中有一个错误;请查看与您的MariaDB服务器版本相对应的手册,以便在第1行'by name'附近使用正确的语法
我正在制作一个我想登录和注册的应用程序,并且能够将csv文件导入数据库,注册和登录工作正常,但是当我想导入csv时,我遇到了这个问题: 错误luminate\Database\QueryException SQLSTATE[42S22]:未找到列:1054“where子句”中的未知列“classe”(SQL:select*fromwhere(=7和=7598)限制1)科目表 账户控制员