laravel-5.6

How to add data to all log records in Laravel 5.6?

ε祈祈猫儿з 提交于 2019-12-02 07:41:33
How to add data to all log records in Laravel? answers how to add data to all log records in Laravel 5.5 and earlier. e.g. the following is added to AppServiceProvider::register(): $monolog = \Log::getMonolog(); $monolog->pushProcessor(function ($record) { $record['extra']['ip'] = \Request::getClientIp(); $record['extra']['path'] = \Request::path(); return $record; }); This doesn't work for Laravel 5.6. I looked through the documentation for 'creating custom channels' but didn't see any obvious way to get the above behavior. The error occurs from @php artisan package:discover -v Symfony

Import vue package in laravel

*爱你&永不变心* 提交于 2019-12-02 06:17:44
问题 What is the corect way to import vue packages in laravel 5.6? It comes with vue and bootstrap preinstall. I see they are all compile in app.js from public directory but I can figure out how to import https://github.com/moreta/vue-search-select and use it. After I tried to import it on my own: Error: ncaught TypeError: Vue.component is not a function At line: Vue.component('search-user', __webpack_require__(42)); Until now I tried this: assets/js/bootstrap.js: import { BasicSelect } from 'vue

How do you create a custom 404 page in Laravel 5.6?

做~自己de王妃 提交于 2019-12-02 04:11:28
I have not found any tutorials out there that address how to "properly" create a 404 page in this specific version of Laravel 5.6. I found some outdated once that is a bit different that how Laravel 5.6 works. Any inputs will help. I found the answer by reading the Laravel Docs "Custom HTTP Error Pages". Create a "Errors" Folder under "/resources/views/" and create a file named "404.blade.php" then add this code: @extends('../layouts.app') @section('content') <div id="login-container" class="container-fluid" style="background-color: lightgray;"> <div class="row"> <div class="col-md-12 mt-1 mb

How can I require composer autoloader in the laravel?

微笑、不失礼 提交于 2019-12-02 03:46:02
问题 I want to install guzzle https://github.com/guzzle/guzzle I read the reference, but I'm confused this section : From that tutorial, asking for require composer autoloader. So seems needed to add require 'vendor/autoload.php'; Where I add the script? I using laravel 5.6 回答1: You don't have to do anything if you are going to install guzzle in Laravel. The example above is for core php actually. Laravel will automatically do it for you. Just run composer require guzzlehttp/guzzle in your

How can I redirect back to previous page after login on vue and laravel?

心不动则不痛 提交于 2019-12-02 03:28:11
I use vue.js 2 and laravel 5.6 My vue component like this : <template> <a v-if="auth" href="javascript:" class="btn btn-default btn-block" @click="add($event)"> Add </a> <a v-else href="javascript:" class="btn btn-default btn-block" @click="logout"> Add </a> </template> <script> export default { data() { return { auth: App.authCheck } }, methods: { add(event) { ... }, logout() { window.location = '/login?red='+window.location.pathname } } } </script> If the user is not logged in, it will call the logout method I try like the code above, but if user login, it does not redirect to the previous

Laravel using Sum and Groupby

◇◆丶佛笑我妖孽 提交于 2019-12-02 02:22:31
I would like to fetch sum of quantity in each month, so that I can display on bar chart quantities against month This is what I thought but didn't workout $data1 = Borrow::groupBy(function($d) { return Carbon::parse($d->created_at)->format('m')->sum('quantity'); })->get(); My table structure Schema::create('borrows', function (Blueprint $table) { $table->increments('id'); $table->integer('member_id'); $table->integer('book_id'); $table->integer('quantity'); $table->integer('status')->default(0); $table->timestamps(); }); that a collection group by not an eloquent groupby if you want to do it

Import vue package in laravel

最后都变了- 提交于 2019-12-02 01:31:53
What is the corect way to import vue packages in laravel 5.6? It comes with vue and bootstrap preinstall. I see they are all compile in app.js from public directory but I can figure out how to import https://github.com/moreta/vue-search-select and use it. After I tried to import it on my own: Error: ncaught TypeError: Vue.component is not a function At line: Vue.component('search-user', __webpack_require__(42)); Until now I tried this: assets/js/bootstrap.js: import { BasicSelect } from 'vue-search-select'; window.BasicSelect = BasicSelect; assets/js/app.js: require('./bootstrap'); window.Vue

How can I require composer autoloader in the laravel?

前提是你 提交于 2019-12-02 00:16:16
I want to install guzzle https://github.com/guzzle/guzzle I read the reference, but I'm confused this section : From that tutorial, asking for require composer autoloader. So seems needed to add require 'vendor/autoload.php'; Where I add the script? I using laravel 5.6 You don't have to do anything if you are going to install guzzle in Laravel. The example above is for core php actually. Laravel will automatically do it for you. Just run composer require guzzlehttp/guzzle in your terminal. (of course in the directory where your laravel project actually is.) And add use GuzzleHttp\Client; at

Laravel 5.6 - How to get auth()->user() or $response->user() in api controller?

北城以北 提交于 2019-12-01 21:30:20
问题 In api.php routes file below, there are public routes and private routes: Route::group(['namespace' => 'API'], function() { // Public routes (auth not required) Route::group([], function() { Route::get('/testauth1', 'TestController@testauth1'); // more public routes... }); // Private routes (auth required) Route::group(['middleware' => 'auth:api'], function() { Route::get('/testauth2', 'TestController@testauth2'); // more private routes... }); }); In the TestContoller these are the 2 methods

htmlspecialchars() expects parameter 1 to be string, array given Laravel 5.6

末鹿安然 提交于 2019-12-01 14:46:30
Already done a research but I don't find the right answer that fit my problem. error: htmlspecialchars() expects parameter 1 to be string, array given(create.blade) <div class="an-single-component with-shadow"> <div class="an-component-body"> @foreach($setting as $setfield) @if($setfield->type === 'smallInteger') <div class"form-group" style="padding:20px"> <div style="display:inline-block"> <P><input type="hidden" name="set_id[{{$setfield->code}}]" value="{{$setfield->id}}">{{$setfield->display_name}}</P> </div> <div class="an-switch-box-wrapper pull-right" style="display:inline-block"> <div