在我的Laravel 5.4生产服务器上,我忘记在实现多授权系统后运行php artisan config:cache命令.这一切都在我的开发环境中工作,但它不想在生产中.自从运行缓存命令以来,我已经解决了所有错误.但是我坚持这个,真的不知道该把它带到哪里.我没有提供任何信息,请随时提出,我会发布.非常感谢你的帮助.
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
public function report(Exception $exception)
{
parent::report($exception);
}
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return …Run Code Online (Sandbox Code Playgroud) 我正在用 laravel 建立一个博客,其中一个帖子有很多标签。我想通过标签过滤所有帖子。意味着如果我单击“PHP”标签,我想获取所有相关的帖子。
这是我的代码
我有两个表,第一个用于标签,第二个表用于帖子链接
标签表
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
$table->string('tags');
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)
关系标签表
public function up()
{
Schema::create('article_tag', function (Blueprint $table) {
$table->increments('id');
$table->integer('article_id')->unsigned();
$table->foreign('article_id')->references('id')->on('articles');
$table->integer('tag_id')->unsigned();
$table->foreign('tag_id')->references('id')->on('tags');
});
}
Run Code Online (Sandbox Code Playgroud)
文章模型
class Article extends Model
{
public function tags()
{
return $this->belongsToMany('App\Tag');
}
}
Run Code Online (Sandbox Code Playgroud)
标签模型
class Tag extends Model
{
public function articles()
{
return $this->belongsToMany('App\Article');
}
}
Run Code Online (Sandbox Code Playgroud)
标签控制器
public function show($id,$name)
{
//here I received tag id and name.
$list->with('articles')->get();
return view('articles.tagshow')->withList($list); …Run Code Online (Sandbox Code Playgroud) 我写了一个工作的Artisan命令,它有两个参数:name和import.然后它创建一个带有名称的MySQL数据库,name并使用importsql dump 导入它.
MySQLCreate.php
exec("mysql -u homestead -psecret -e \"create database "
. $this->argument('name') . "\"");
exec("mysql -u homestead -psecret " . $this->argument('name')
. "<" . $this->argument('import'));
Run Code Online (Sandbox Code Playgroud)
这有效但我相信有更好的方法来实现这一目标.我担心将密码硬编码到exec命令中并且非常确定exec在Laravel应用程序内部使用并不是最好的方法.
通常在Laravel中,您会获得一个带有所有参数的请求包。但是在服务提供商中却并非如此。但是我们确实有request()对象。
但是,它不包含资源路由中给定的url参数。
因此,我正在寻找一种从路由中检索{id}的方法。
我试过了:
request()->route('id')
Route::get('id')
Request::get('id')
Run Code Online (Sandbox Code Playgroud)
所有这些都返回null
我已经尝试过在laravel中使用邮件功能,但没有成功。建议我如何在laravel中发送电子邮件。这是我在Controller中的代码。
$Body = "$CusName ($UID - $CusEmail ) from $SiteID";
$param = array('User'=>$Use, 'Pass'=>$Pass,'Body'=>$Body,'SiteID'=>$SiteID);
$Email['To']="xyz@gmail.com";
$Email['Sender']=$CusEmail;
$Email['Body']=$data;
$mail= mail("xyz@gmail.com","My subject",$data);
Run Code Online (Sandbox Code Playgroud)
谢谢
laravel ×5
php ×4
laravel-5 ×3
artisan ×1
eloquent ×1
kernel ×1
laravel-5.1 ×1
laravel-5.2 ×1
mysql ×1
session ×1