小编Maj*_*nia的帖子

PhpStorm Field通过魔术方法访问

我已经在我的codeigniter库文件夹中点燃了数据表库.

图书馆的一些代码

class Datatables
{
    /**
     * Global container variables for chained argument results
     *
     */
    protected $ci;
    protected $table;
    protected $distinct;
    protected $group_by;
    protected $select         = array();
    protected $joins          = array();
    protected $columns        = array();
    protected $where          = array();
    protected $filter         = array();
    protected $add_columns    = array();
    protected $edit_columns   = array();
    protected $unset_columns  = array();

    /**
     * Copies an instance of CI
     */
    public function __construct()
    {
        $this->ci =& get_instance();
    }
Run Code Online (Sandbox Code Playgroud)

然后我在模型中调用了库

class Common_Model extends MY_Model{

    function __construct(){
        parent::__construct(); …
Run Code Online (Sandbox Code Playgroud)

php codeigniter phpstorm

55
推荐指数
3
解决办法
2万
查看次数

Laravel 5如何验证路由参数?

我想验证"表单请求"中的路由参数,但不知道如何操作.

下面是代码示例,我正在尝试:

路线

// controller Server
Route::group(['prefix' => 'server'], function(){
    Route::get('checkToken/{token}',['as'=>'checkKey','uses'=> 'ServerController@checkToken']);
});
Run Code Online (Sandbox Code Playgroud)

调节器

namespace App\Http\Controllers;


use App\Http\Controllers\Controller;

use Illuminate\Http\Request;
use App\Http\Requests;


class ServerController extends Controller {
    public function checkToken( \App\Http\Requests\CheckTokenServerRequest $request) // OT: - why I have to set full path to work??
        {   
            $token = Token::where('token', '=', $request->token)->first();      
            $dt = new DateTime; 
            $token->executed_at = $dt->format('m-d-y H:i:s');
            $token->save();

            return response()->json(json_decode($token->json),200);
        }
}
Run Code Online (Sandbox Code Playgroud)

CheckTokenServerRequest

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CheckTokenServerRequest extends Request {

        //autorization

        /**
         * Get the validation rules …
Run Code Online (Sandbox Code Playgroud)

routes laravel laravel-5 laravel-validation laravel-request

27
推荐指数
4
解决办法
1万
查看次数

使用Blade获取Laravel 5中当前URL的最后一部分

如何动态获取当前URL的最后一部分没有'/'?

例如:

www.news.com/foo/bar
get - > bar

www.news.com/foo/bar/fun
get - >有趣

在当前视图中放置函数或如何实现它的位置?

laravel laravel-5 laravel-5.1 laravel-5.2 laravel-blade

11
推荐指数
6
解决办法
3万
查看次数

如何修复Laravel 5.1 - 404 Not Found?

我试图第一次使用Laravel 5.1.我能够安装它并https://sub.example.com/laravel/public/显示应该是什么.但是,我创建的视图给了我404错误页面未找到.

这是我到目前为止所做的:

我创建了一个控制器 laravel\app\Http\controllers\Authors.php

这是Authors.php文件背后的代码

<?php

class Authors_Controller extends Base_Controller {

    public $restful = true;

    public function get_index() {
        return View::make('authors.index')
            ->with('title', 'Authors and Books')
            ->with('authors', Author::order_by('name')->get());
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我创建了一个视图 laravel\resources\views\Authors\index.blade.php

这是index.blade.php文件背后的代码

@layout('layouts.default')


@section('content')
    Hello, this is a test
@endsection
Run Code Online (Sandbox Code Playgroud)

然后我创建了一个布局 laravel\resources\views\layouts\default.blade.php

这是default.blade.php文件背后的代码

<!DOCTYPE html>
<html>
    <head>
        <title>{{ $title }}</title>
    </head>
    <body>

    @if(Session::has('message'))
        <p style="color: green;">{{ Session::get('message') }}</p>
    @endif

    @yield('content')
    Hello - My first test
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

最后我创建了一条路线 laravel\app\Http\routes.php

<?php
Route::get('/', …
Run Code Online (Sandbox Code Playgroud)

php apache .htaccess mod-rewrite laravel

9
推荐指数
2
解决办法
4万
查看次数

Golang Gin 使用新变量重定向和渲染模板

我试图在函数的某些进程之后传递一些变量Handler。如何redirect在新页面中将一些 json 变量传递给这个新模板?

// main package
func main() {
    apiRoutes := gin.Default()
    apiRoutes.POST("api/ipg/send", controllers.GatewayIpgSendHandler)
    apiRoutes.GET("ipg/:token", controllers.GatewayIpgRequestHandler)

    // ... rest of the codes
}


// controllers package
func GatewayIpgRequestHandler(context *gin.Context) {
    // some processes that lead to these variables.
    wage := 123
    amount := 13123
    redirectUrl := "www.test.com/callback"


    // What should I do here to pass those
    // three variables above to an existing `custom-view.tmpl` file
    // in my `templates` folder.

}
Run Code Online (Sandbox Code Playgroud)

这是 php(laravel) 相当于我想做的事情。

go go-gin

8
推荐指数
1
解决办法
2万
查看次数

MongoDB - 无权执行命令

我已成功启用 MongoDB 上的授权,并在 admin 数据库上创建了一个帐户,然后为我的数据库创建了一个名为 test 的帐户。连接到我的测试数据库的以下连接字符串成功运行:mongo --host 192.168.17.52 --port 27017 -u user1 -p password --authenticationDatabase test

我现在唯一的问题是,我无法执行诸如:show dbs 之类的命令。当我尝试这样做时,我收到以下错误:

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, lsid: { id: UUID(\"a1d5bc0d-bc58-485e-b232-270758a89455\") }, $db: \"admin\" }"
Run Code Online (Sandbox Code Playgroud)

我一直在许多在线资源上帮助解决这个问题,但没有运气,有没有办法解决这个问题?似乎我的用户无法访问 admin 数据库,有没有办法将此访问权限授予我的用户,以便我可以运行 show dbs 之类的必要命令?

任何帮助深表感谢!:)

authentication shell roles mongodb createuser

7
推荐指数
1
解决办法
2万
查看次数

Laravel 通行证适用于与“用户”不同的表

我目前正在使用 Laravel Passport 开发多重身份验证,因此该应用程序将拥有用户和设备,当我尝试注册设备时,它会将其保存到设备数据库中,如果我尝试登录,它会给我持有者令牌。但现在我想获取用户中间件“auth:api”或其他方式通过令牌获取设备信息,但令牌似乎存储在 oauth_access_token 表中并带有 user_id 。那么有没有办法将 laravel 护照用于另一个除了用户之外的表?谢谢 ?

这是我的设备代码:

<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;

use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;

class Device extends Authenticatable{


    use Notifiable,HasApiTokens;

   protected $fillable = [
        'name', 'password'  ,
    ];
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = …
Run Code Online (Sandbox Code Playgroud)

php mysql laravel

6
推荐指数
2
解决办法
7514
查看次数

Laravel Horizo​​n 限制和优化

Laravel Horizo​​n 中maxProcesses、 的数量supervisors和 s 的总数之间是否有任何经验法则或任何逻辑关系?queue

如果我有 15 个主管和 40 个队列(每个主管根据其类别有多个队列)怎么办?maxProcesses我可以分配给每个主管的最大数量是多少(假设平衡auto)?
我想知道是否有通过调整这些数字来获得更好性能的经验法则,例如,队列的数量是否supervisor-x不应超过队列总数,以及maxProcesses基于操作系统规范的数量是否不应超过特定数量运行进程。

这些数字之间有什么逻辑关系吗?有没有关于这个问题的好的文档?我已经在主管Laravel Horizo​​n 文档上看过这篇文档,但还没有找到我的问题的答案。

process worker supervisord laravel laravel-horizon

6
推荐指数
1
解决办法
1159
查看次数

添加第二个操作或链接到 Laravel 通知

我正在使用 Laravel 发送通知,但无法弄清楚如何发送第二个操作。这是我的toMail方法代码:

public function toMail($notifiable)
    {
    return (new MailMessage)
        ->subject($this->options['subject'])
        ->greeting($this->options['greeting'])
        ->line($this->options['contentParagraph1'])
        ->line($this->options['contentParagraph2'])
        ->action('Facebook', 'https://www.facebook.com/')
        ->line($this->options['contentParagraph5'])
        ->action('LinkedIn', 'https://www.linkedin.com/')
        ->line($this->options['contentParagraph3'])
        ->line($this->options['contentParagraph4'])
        ->salutation($this->options['salutation']);
}
Run Code Online (Sandbox Code Playgroud)

我得到的只是第二个动作。看起来第二个操作覆盖了第一个操作。有没有办法保留这两个操作或使用链接而不是按钮?

php notifications laravel laravel-notification

4
推荐指数
1
解决办法
5281
查看次数

如何在Laravel中排队发送电子邮件

我尝试将电子邮件发送到队列中,但无法正常工作。

Mail::queue('emails.mailsubscribe', ['email'=>$email], 
    function($message) use($email)
    {
       $message->to('user@xxx.in')->subject('Subscribe: XXXXX');
    });
Run Code Online (Sandbox Code Playgroud)

email laravel

4
推荐指数
1
解决办法
5964
查看次数