laravel-5.4

Laravel: SQLSTATE[HY000] [2002] Connection refused

不问归期 提交于 2019-12-05 20:12:13
I am using Vagrant with fresh laravel 5.4 installed. After I run auth I have ran the migrate to migrate the MySQL tables. All of these process successful but when I try to login or register to test the system I am getting error: SQLSTATE[HY000] [2002] Connection refused. But my database working perfect since I already able to migrate the tables. Whats possible solution could be? check attached image (I'm using Ubuntu 16.04) Try changing your DB_HOST from 127.0.0.1 to localhost. and if still not working try using the default mysql port to 3306 if you use laravel maybe your PDO PHP Extension not

Laravel 5.4 wrongly mix HTML components in Markdown Mailable

痞子三分冷 提交于 2019-12-05 17:16:08
问题 I had ordinary Mailable that had some hardcoded content. I've published mailable views, changed content to markdown and replaced ->view with ->markdown . Now mail have nicely formated markdown. However Laravel after compiling that markdown will pick HTML component definitions, for reasons I can not phantom. And that after it used Markdown version for message, so it's mixing both kinds in a single Mailable markdown view! I've tried: php artisan cache:clear php artisan view:clear adding

How to implement eloquent events in laravel using commmon Trait for all models

强颜欢笑 提交于 2019-12-05 16:21:51
I am using laravel 5.4 to create a web app. I have created a trait to implement events for created, updated, deleted and restored eloquent events. I have created a trait as below: <?php namespace App\Traits; use Auth; use App\Master\Activity; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; /** * Class ModelEventLogger * @package App\Traits * * Automatically Log Add, Update, Delete events of Model. */ trait ActivityLogger { /** * Automatically boot with Model, and register Events handler. */ protected static function boot() { parent::boot

Pusher is not defined! Laravel 5.4 with Laravel Echo

寵の児 提交于 2019-12-05 14:27:00
I don't know what is wrong with my codes Here's my app.js /** * First we will load all of this project's JavaScript dependencies which * include Vue and Vue Resource. This gives a great starting point for * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ Vue.component('chat-message', require('./components/ChatMessage.vue')); Vue

Laravel Blade - Chain/Embed multiple layouts

蹲街弑〆低调 提交于 2019-12-05 13:11:54
问题 In my favorite templating frameworks they typically have the ability to nest layouts. Is this something that is possible in Blade? For example... master.blade.php <html> <head><!-- stuff --></head> <body> @yield('content') </body> </html> nav.blade.php @extend('master') <nav> <!-- nav content --> </nav> @yeild('content') breadcrumb.blade.php @extend('nav') <breadcrumb> <!-- breadcrumb content --> </breadcrumb> @yield('content') home.blade.php @extend('nav') @section('content') <home> <!--

Dropzone createThumbnailFromUrl() issue

时间秒杀一切 提交于 2019-12-05 08:12:46
I need to add pre-existing image files to dropzone by using Laravel 5.4 . This is why I use createThumbnailFromUrl() function. But it does not generate images properly. Instead it shows them in blank way. I used that link ( jsfiddle ) for that purpose. I googled a lot, tried several ways, but it did not help: Below is my code: <script type="text/javascript" src='{{asset("js/dropzone/min/dropzone.min.js")}}'></script> <script type="text/javascript"> Dropzone.options.addImages = { paramName: "file", // The name that will be used to transfer the file addRemoveLinks: true, // The setting up of the

laravel 5.4 modify data before validation in request [closed]

你。 提交于 2019-12-05 08:04:04
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have my custom Request, which extends the Backpack CrudController. Now I would like to override the prepareForValidation of the ValidatesWhenResolvedTrait since it looks like the right place to modify my incoming data, but I can't figure out how ... So my first question is, can I override this method? Its protected ... protected function prepareForValidation() And my second question, how can I modify my input

Laravel 5.4 - 'updateOrCreate' method. Check If record was 'updated' or 'created'

让人想犯罪 __ 提交于 2019-12-05 07:07:35
Using the method updateOrCreate , is there a way to know which if a record was updated or created? UPDATE: I need to use this feature to return 201 , for created record, or 204 for updated record. Thank you. Since updateOrCreate returns the model instance. https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Eloquent/Builder.php#L374 You can check that a record was recently created using: $instance->wasRecentlyCreated https://github.com/laravel/framework/blob/5.3/src/Illuminate/Database/Eloquent/Model.php#L1593 来源: https://stackoverflow.com/questions/44238257/laravel-5-4

Laravel validation Error messages to string

时光怂恿深爱的人放手 提交于 2019-12-05 02:31:23
问题 I want to convert laravel validation error array to a comma separated string. This is to use in an api service for an ios application. So that the iOs developer can process error messages easily. I tried, $valArr = []; foreach ($validator->errors() as $key => $value) { $errStr = $key.' '.$value[0]; array_push($valArr, $errStr); } if(!empty($valArr)){ $errStrFinal = implode(',', $valArr); } But it is not working. 回答1: You should do like this : $errorString = implode(",",$validator->messages()-

How can I change the public path to something containing an underscore in Laravel Mix?

这一生的挚爱 提交于 2019-12-04 23:11:39
In Laravel 5.4 Mix was introduced to compile assets and maintain the asset pipeline. Mix defaults to your public directory being named public . In many cases, including mine, my public directory is called something else. In my case, it's public_html . How can I change the public directory where assets are compiled to? I have tried changing the paths within webpack.min.js to: mix.js('resources/assets/js/app.js', 'public_html/assets/js') .sass('resources/assets/sass/app.scss', 'public_html/assets/css'); Unfortunately this compiles to: - public |- _html |-- assets |--- css |--- js |- fonts In