微信公众号消息

思玉:
http://local.meirenji.com/api/v2/auth/login?mobile=14400000001&password=12345678

微信公众平台测试号:
http://local.meirenji.com/api/v2/auth/login?mobile=14400000001&password=12345678

思玉:
http://local.meirenji.com/api/v2/customer/house/house_list

微信公众平台测试号:
http://local.meirenji.com/api/v2/customer/house/house_list

思玉:
http://sandbox.b2.meirenji.vip/

微信公众平台测试号:
http://sandbox.b2.meirenji.vip/

思玉:
Route::any('/test1', '\App\Brands\Beauty\Controllers\Manager\AppController@test');

微信公众平台测试号:
Route::any('/test1', '\App\Brands\Beauty\Controllers\Manager\AppController@test');

思玉:
SELECT
shop_id,sum(total_price)
FROM
`hl_my_order`
WHERE
`brand_id` = 15
AND EXISTS ( SELECT * FROM `hl_shop` WHERE `hl_my_order`.`shop_id` = `hl_shop`.`id` AND `delete_time` = 0 AND `hl_shop`.`delete_time` = 0 )
AND ( `pay_status` = 1 OR `is_credit` = 1 )
AND `hl_my_order`.`delete_time` = 0

group by shop_id order by sum(total_price) desc;

思玉:
laravel orm with wherehas
https://wenku.baidu.com/view/b5060bd2f51fb7360b4c2e3f5727a5e9856a27b9.html

微信公众平台测试号:
laravel orm with wherehas
https://wenku.baidu.com/view/b5060bd2f51fb7360b4c2e3f5727a5e9856a27b9.html

思玉:
select * from roles where JSON_CONTAINS(brand_ids, '[83, 15]');

微信公众平台测试号:
select * from roles where JSON_CONTAINS(brand_ids, '[83, 15]');

思玉:
laravel json_contains https://segmentfault.com/q/1010000008909173/a-1020000009481327

微信公众平台测试号:
laravel json_contains https://segmentfault.com/q/1010000008909173/a-1020000009481327

思玉:
多业态路由实现
app/Providers/RouteServiceProvider.php

微信公众平台测试号:
多业态路由实现
app/Providers/RouteServiceProvider.php

思玉:
$list = $query->orderBy('id','desc')->get()->map(function ($item) {
return [ 'id' => $item->id,
'admin_id' => $item->admin_id,
'tenant_id' => $item->tenant_id,
'account_id' => $item->admin->account_id,
];
});

思玉:
//销售目录商品列表
public static function goodsList($params){
$sales_catalog_id = $params['sales_catalog_id'];
//递归显示所有的子销售目录
$all_id = SalesCatalogService::allSubId($sales_catalog_id);
$all_id[] = $sales_catalog_id;
$status = 1;
$list = SalesCatalogGoods::select('id','sales_catalog_id','goods_id','rank')->whereIn('sales_catalog_id',$all_id)->with(['product' => function ($q) use ($status) {
$q->select('id','product_name')->where('product_status', $status);
}])->whereHas('product',function($q) use ($status) {
$q->where('product_status',$status);
})->orderBy('rank','asc')->orderBy('updated_at','desc')->get();
$list = $list->map(function ($item) {
return [ 'sales_catalog_id' => $item->sales_catalog_id,
'id' => $item->id,
'rank' => $item->rank,
'goods_id' => $item->goods_id,
'goods_name' => $item->product->product_name,
];
});
return $list;
}

思玉:
外键约束http://c.biancheng.net/view/2441.html

思玉:
D:\phpstudy_pro\WWW>composer create-project --prefer-dist laravel/laravel blog "7.30.*"

思玉:
Route::any('index', 'IndexController@index');

思玉:
D:\phpstudy_pro\WWW\blog>php artisan make:controller IndexController
Controller created successfully.

思玉:
自定义exception https://blog.csdn.net/hjh15827475896/article/details/84801163

思玉:
自定义异常处理类 https://blog.csdn.net/qq_36514588/article/details/102681277

思玉:
laravel验证中文化https://blog.csdn.net/w18838020329/article/details/105381950/

思玉:
.env时区APP_TIMEZONE=PRC
DB_TIMEZONE=+08:00

思玉:
laravel-jwt https://www.cnblogs.com/mouseleo/p/10778923.html

思玉:
D:\phpstudy_pro\WWW\laravel>composer require spatie/laravel-permission:^4.4

思玉:
二维重置appends
$info = $product->select('id','product_name')->limit(10)->get()->each->setAppends([]);

思玉:
一维重置appends $info = $product->select('id','product_name')->first()->setAppends([]);

思玉:
$product = new Product();
$info = $product->select('id','product_name')->first();
$info = $info->append('is_adult');
$info = $product->select('id','product_name')->limit(10)->get();
$info->each->append('is_adult');

Product.php
public function getIsAdultAttribute()
{
return $this->id;
}

思玉:
laravel日期不正确
.env
APP_TIMEZONE=PRC
DB_TIMEZONE=+08:00

basemodel
toDateTimeString();//这里使用toDateTimeString,不受Carbon中时区的影响
}
}

思玉:
sql慢查询原因分析 https://learnku.com/articles/68200

思玉:
laravel验证唯一
use Illuminate\Validation\Rule;
'sales_catalog_name' => ['required', 'string','max:10', Rule::unique('hl_sales_catalog')->ignore(request('id'))->where(function ($query) {
    $query->whereNotIn('id', [100]);
})],

思玉:
'sales_catalog_name' => ['required', 'string','max:10', Rule::exists('hl_sales_catalog')->where(function ($query) {
    $query->whereNotIn('id', [100]);
})],

思玉:
菜鸟教程go https://m.runoob.com/go/

思玉:
beego私房菜https://www.kancloud.cn/mylxnet/beego/1935867

思玉:
    //获取父类所有的子类
    public static function getAllChild($array,$id){
        $array = SalesCatalog::select('id','parent_id')->where('parent_id',$id)->get()->toArray();
        $arr = array();
        foreach($array as $v){
            if($v['parent_id'] == $id){
                $arr[] = $v['id'];
                $arr = array_merge($arr,self::getAllChild($array,$v['id']));
            };
        };
        return $arr;
    }
    //获取子类所有的父类
    public static function allMainId($array,$id){
        $array = SalesCatalog::select('id','parent_id')->where('id',$id)->get()->toArray();
        $arr = array();
        foreach($array as $v){
            if($v['id'] == $id){
                $arr[] = $v['parent_id'];
                $arr = array_merge($arr,self::allMainId($array,$v['parent_id']));
            };
        };
        return $arr;
    }

思玉:
try {
    SalesCatalogService::test();
} catch (\Exception $e) {
    return $this->jsonError($e->getMessage());
}    

service
public static function test(){
    throw new \Exception("出现错误");
}

思玉:
获取器针对字段

思玉:
        $author = new Author();
        $list = $author::where('id','>=',1)->with([            'book' => function($query){
                $query->select('id','author_id', 'name')->where('id','>=',1)->with([                    'publisher:book_id,name','post'=> function($query){
                    $query->select('book_id', 'comment')->where('id','>=',1);
                }]);
            }])
        ->get();
        dd($list->toArray());

思玉:
        $id = 3;
        $list = Author::where('id', '>=', 1)
            ->where(function($query) use ($id) {
                $query->whereHas('book.post',function ($q) use ($id){
                   if($id){
                       $q->where('id','>',$id);
                   }
                });
            })
        ->orderBy('id','desc')->get();
        dd($list->toArray());

思玉:
        $id = 1;
        $list = Author::where('id', '>=', 1)
            ->where(function($query) use ($id) {
                $query->whereHas('book',function ($query) use ($id){
                    if($id){
                        $query->where('id','>',$id);
                    }
                    $query->whereHas('post',function($query) use($id) {
                        $query->where('id','>',$id);
                    });
                });
            })
        ->orderBy('id','desc')->get();
        dd($list->toArray());

思玉:
        $params = $request->all();
        try{
            $validator = Validator::make($params, [                'phone' => 'required',
                'code' => 'required',
            ]);
            if ($validator->fails()) {
                $error = $validator->errors()->first();
                throw new \Exception($error);
            }
        }catch (\Exception $e){
            return $this->jsonError($e->getMessage());
        }

思玉:
use Illuminate\Support\Facades\Validator;

思玉:
        $data = [            [                "name" => 'php',
                "author_id" => 1,
            ],
            [                "name" => 'asp',
                "author_id" => 2,
            ],
        ];
        Book::insert($data);
        $activity = new Book();
        echo $activity->getTable();
        echo Activity::getModel()->getTable();

思玉:
D:\phpstudy_pro>git checkout master
D:\phpstudy_pro>git checkout -b yansy-test
D:\phpstudy_pro>git push --set-upstream origin yansy-test
D:\phpstudy_pro>git push origin --delete yansy-test
D:\phpstudy_pro>git branch -D yansy-test

思玉:
Unix 系统中:每行结尾只有 "<换行>",即 "\n";
Windows 系统中:每行结尾是 "<回车><换行>",即 "\r\n";
Mac 系统中:每行结尾是 "<回车>",即 "\r"。

思玉:
https://chrome.google.com/webstore/search/fehelper?hl=zh-CN

思玉:
laravel运行原理 https://www.gxlcms.com/mysql-464947.html

思玉:
permission缓存php artisan permission:cache-reset

思玉:
        $list = $product->select('id','product_name')
        ->where('id','>',9251)
        ->get()->each(function($item){
            $item->append(['get_pro_price','get_name']);
        });

思玉:
Attribute可以给返回值中加上数据表中没有的值,或者修改查到的结果的格式,或者对查询结果某些字段进行修改后返回

思玉:
model中
    public function getCreateTimeAttribute()
    {
        return $this->attributes['created_at'];
    }

思玉:
'created_at' => $this->create_time

思玉:
        $item= Product::select(['id', 'product_name','main_media_id'])->get()->each(function($row){
            $row->setHidden(['main_media_url']);
        });

思玉:
laravel9 https://readerstacks.com/how-to-implement-jwt-auth-in-laravel-9/

思玉:
laravel9-jwt

思玉:
Laravel 提示Route [login] not defined.错误https://www.dvy.com.cn/2020/07/09/6837.html

微信公众平台测试号:
Laravel 提示Route [login] not defined.错误https://www.dvy.com.cn/2020/07/09/6837.html

思玉:
permission清除缓存 php artisan permission:cache-reset

微信公众平台测试号:
permission清除缓存 php artisan permission:cache-reset

思玉:
php artisan cache:forget spatie.permission.cache
php artisan cache:clear

微信公众平台测试号:
php artisan cache:forget spatie.permission.cache
php artisan cache:clear

思玉:
there is no permission named 'xxxxxx' for guard 'api'检查一下数据库表中guard_name及模型中protected $guard_name

微信公众平台测试号:
there is no permission named 'xxxxxx' for guard 'api'检查一下数据库表中guard_name及模型中protected $guard_name

微信公众平台测试号:
微信消息

思玉:
http://admin.yuanchengzhushou.cn:8099/send.php?openid=o7qRAs_Y1a1Weitn10DaKTeWGRhk&content=%E5%BE%AE%E4%BF%A1%E6%A8%A1%E6%9D%BF%E6%B6%88%E6%81%AF%E6%B5%8B%E8%AF%95

微信公众平台测试号:
http://admin.yuanchengzhushou.cn:8099/send.php?openid=o7qRAs_Y1a1Weitn10DaKTeWGRhk&content=%E5%BE%AE%E4%BF%A1%E6%A8%A1%E6%9D%BF%E6%B6%88%E6%81%AF%E6%B5%8B%E8%AF%95

微信公众平台测试号:
微信消息

微信公众平台测试号:
微信消息

思玉:
laravel联表查询join表取别名软删除
$list = (new Admin())->setTable('admin')->from('hl_admin as admin')->join('hl_tenant_admin as h','admin.id','=','h.tenant_id')->get();
dd($list->toArray());

微信公众平台测试号:
laravel联表查询join表取别名软删除
$list = (new Admin())->setTable('admin')->from('hl_admin as admin')->join('hl_tenant_admin as h','admin.id','=','h.tenant_id')->get();
dd($list->toArray());

思玉:
laravel getLastSql
$list = (new Admin())->setTable('admin')->from('hl_admin as admin')->join('hl_tenant_admin as h','admin.id','=','h.tenant_id');
\Log::info($list->toSql());
$list = $list->get();
dd($list->toArray());

微信公众平台测试号:
laravel getLastSql
$list = (new Admin())->setTable('admin')->from('hl_admin as admin')->join('hl_tenant_admin as h','admin.id','=','h.tenant_id');
\Log::info($list->toSql());
$list = $list->get();
dd($list->toArray());

思玉:
laravel latest('created_at')
oldest('created_at')

微信公众平台测试号:
laravel latest('created_at')
oldest('created_at')

思玉:
批量插入
$data= [    ['user_name'=>'123'],
    ['user_name'=>'abc'],
];
$user = new Admin();
$user->insert($data);

微信公众平台测试号:
批量插入
$data= [    ['user_name'=>'123'],
    ['user_name'=>'abc'],
];
$user = new Admin();
$user->insert($data);

思玉:
model软删除字段名修改
use Illuminate\Database\Eloquent\Builder;
    public static function bootSoftDeletes()
    {
        static::addGlobalScope('admin_num', function (Builder $builder) {
            $builder->where(self::$_table . '.admin_num', 0);
        });
    }

思玉:
php抽象类和接口https://m.php.cn/article/462607.html

微信公众平台测试号:
php抽象类和接口https://m.php.cn/article/462607.html

思玉:
D:\phpstudy_pro\WWW\meirenji-backend>php artisan migrate --path=database\migrations\2022_08_16_142725_create_hl_cooperation_product.php

微信公众平台测试号:
D:\phpstudy_pro\WWW\meirenji-backend>php artisan migrate --path=database\migrations\2022_08_16_142725_create_hl_cooperation_product.php

思玉:
D:\phpstudy_pro\WWW\meirenji-backend>php artisan make:migration create_hl_cooperation_product_price

微信公众平台测试号:
D:\phpstudy_pro\WWW\meirenji-backend>php artisan make:migration create_hl_cooperation_product_price

思玉:
laravel orderby in
$id = [2,3,109,108,13];
$list =UserList::select('id','mobile')->whereIn('id',$id)->orderByRaw("FIELD(id,".implode(", ", $id).")")->get();

微信公众平台测试号:
laravel orderby in
$id = [2,3,109,108,13];
$list =UserList::select('id','mobile')->whereIn('id',$id)->orderByRaw("FIELD(id,".implode(", ", $id).")")->get();

思玉:
Laravel使用maatwebsite/excel实现Excel/CSV文件导入导出及常见问题解决
https://phpartisan.cn/news/49880.html

微信公众平台测试号:
Laravel使用maatwebsite/excel实现Excel/CSV文件导入导出及常见问题解决
https://phpartisan.cn/news/49880.html

思玉:
Laravel Excel(maatwebsite/excel )导入增加错误提示
https://blog.csdn.net/weixin_44545251/article/details/124062423

微信公众平台测试号:
Laravel Excel(maatwebsite/excel )导入增加错误提示
https://blog.csdn.net/weixin_44545251/article/details/124062423

思玉:
laravel导出excel合并单元格 https://blog.csdn.net/qq_41688060/article/details/108827432

微信公众平台测试号:
laravel导出excel合并单元格 https://blog.csdn.net/qq_41688060/article/details/108827432

思玉:
php算法 https://blog.csdn.net/json_ligege/category_6193079.html

微信公众平台测试号:
php算法 https://blog.csdn.net/json_ligege/category_6193079.html

    A+
发布日期:2022年09月02日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: