laravel-5.4

Dynamically hide Laravel barryvdh debugbar

。_饼干妹妹 提交于 2019-12-24 12:35:15
问题 I could not able to hide Laravel Debugbar dynamically, i.e on the run time. I have tried the following from parent Controller class constructor: <?php namespace App\Http\Controllers; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; public $foo = 'null'; public function __construct() { \Debugbar::disable(); // and also config(['debugbar.enabled' => false]); .... All of the above tries failed. I'd like to mention that controller is the parent

Laravel 5.4 HTTP testing - method seeInElement

喜夏-厌秋 提交于 2019-12-24 08:55:53
问题 In Laravel 5.3 there was a seeInElement method which would check the text inside an element based on a CSS selector. https://laravel.com/api/5.3/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.html#method_seeInElement In 5.4 this has been moved to Laravel Dusk. I still use the HTTP Tests with 5.4 ( https://laravel.com/docs/5.4/http-tests ) because they're faster for the testing I want to do, but it's now missing this method. Is there a way to get this back? 回答1: You need the laravel

How to generate fpdf?

笑着哭i 提交于 2019-12-24 08:48:36
问题 I am getting error 'Class "Fpdf" not found'. use Fpdf; Fpdf::AddPage(); Fpdf::SetFont('Courier', 'B', 18); Fpdf::Cell(50, 25, 'Hello World!'); Fpdf::Output(); 回答1: Install using Composer composer require codedge/laravel-fpdf Add the following lines to your config/app.php 'providers' => [ // ... Codedge\Fpdf\FpdfServiceProvider::class, ], 'aliases' => [ // ... 'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class, ] Use it (omit use Fpdf ): Fpdf::AddPage(); Fpdf::SetFont('Courier', 'B', 18); Fpdf::Cell

Toastr not showing up in laravel 5.4

人走茶凉 提交于 2019-12-24 07:59:44
问题 I tried to use Toast notification, I think I have included everything alright. It can be seen on page source that generated after the action, but it's not showing the notification on the page. The includes: <link href="{{ asset('css/toastr.min.css') }}" rel="stylesheet"> <script src="{{ asset('js/toastr.min.js') }}"></script> The call: <script> @if(Session::has('success')) toastr.success("{{ Session::get('success') }}") @endif </script> The controller: $this->validate($request, [ 'name' =>

How to validation slug in laravel 5.4.24

无人久伴 提交于 2019-12-24 06:58:06
问题 How to create unique slug in laravel and validate them ? Here is my validation code: $this->validate($request,[ 'company_name' => 'required|unique:admin_users,company_name,slug|max:191', ]); Here is my slug code: $db_filed->company_name = str_slug($request->company_name, '-'); Thanks. 回答1: Setup a FormRequest to do the validation for the route with the rules like this: https://laravel.com/docs/5.4/validation#form-request-validation public function rules() { return [ 'company_name' =>

Laravel Artisan Hangs using Memory Until Freeze

情到浓时终转凉″ 提交于 2019-12-24 06:48:32
问题 With Laravel 5.4 Artisan will not run and uses a lot of memory, it worked a long while before with the same versions (besides PHP 7.0.14 to 7.0.15 maybe?). Problem : any $ ./artistan command does nothing. While watching htop I notice the memory climb from 2gb to 4gb very quickly. Once I cancel it, it jumps back down. What Im Using Ubuntu Linux Xenial x64 (Local Development) Apache2.4 MySQL 5.7 PHP 7.0.15 Laravel 5.4 Composer 1.3.2 PHP Extensions Loaded [PHP Modules] bz2 Core ctype curl date

Access relational data of many to many relationship with multiple database connection with different server

瘦欲@ 提交于 2019-12-24 03:22:06
问题 I'm working with multiple database connection on different servers. i.e, host1 and host2 . My default database connection is host2. My project have two tables. users exists on host1 and tasks exists on host2 . There is a many to many relationship on both tables. Pivot table for this relationship is task_users which exists on host2 . My model files are here. User.php class User extends Authenticatable { protected $connection = 'host1'; public function tasks() { return $this->belongsToMany(Task

Laravel 5.4 redirect taking method from request object

狂风中的少年 提交于 2019-12-24 03:11:18
问题 Recently I have started a Laravel 5.4 project and I found something I don't quite understand and I'm posting this question hoping to solve this issue and find out if it's expected behaviour or a bug. The thing is, I'm submitting an update form which looks like so: <form id="post-form" action="{{url('admin/posts/'.$post->id)}}" method="POST"> {{ csrf_field() }} {{ method_field('PUT') }} <!-- Some fields --> </form> And I try to validate that request on the controller method: $validator =

Laravel 5.4 redirect taking method from request object

 ̄綄美尐妖づ 提交于 2019-12-24 03:09:12
问题 Recently I have started a Laravel 5.4 project and I found something I don't quite understand and I'm posting this question hoping to solve this issue and find out if it's expected behaviour or a bug. The thing is, I'm submitting an update form which looks like so: <form id="post-form" action="{{url('admin/posts/'.$post->id)}}" method="POST"> {{ csrf_field() }} {{ method_field('PUT') }} <!-- Some fields --> </form> And I try to validate that request on the controller method: $validator =

how do I load a Vue component in Laravel 5.4?

谁说我不能喝 提交于 2019-12-24 02:27:09
问题 I've run npm run watch and received the message This dependency was not found: * in ./resources/assets/js/app.js To install it, you can run: npm install --save So I ran npm install --save but still get the same message. From my understanding, I need npm run or npm run watch to load the Vue files in Laravel. For example, in 'resources/assets/js/components/Example.vue' file, I made edits to it but when I load up 'resources/views/welcome.blade.php' file, which I have as follows, the update from