laravel-5.3

How to Create NPM packages from a .vue file

纵然是瞬间 提交于 2019-12-05 01:39:34
问题 I have a index.js file with: import MyComponent from './components/MyComponent.vue'; module.exports = MyComponent; I want to publish this as npm package so that i can use this component by npm install my-component When i try to test by importing component from compiled js file got [Vue warn]: Failed to mount component: template or render function not defined But work fine when i import from .vue file. 回答1: You just need to add a package.json in the directory and in main field of package.json

Laravel 5.3 Passport Custom Grants?

耗尽温柔 提交于 2019-12-05 00:51:53
I know I am not the only person who has come up to this point. Does anyone know how to properly implement a custom grant in Laravel(5.3) Passport? Or Have a good link/tutorial to reference how to properly do it? I know there's this package: https://github.com/mikemclin/passport-custom-request-grant But I'm asking for a more "Do it yourself" approach. Thank you in advance. Francisco Daniel namespace App\Providers; use App\Auth\Grants\FacebookGrant; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Laravel\Passport\Bridge\RefreshTokenRepository; use Laravel

Laravel 5.3 Storage::put creates a directory with the file name

岁酱吖の 提交于 2019-12-04 22:49:51
I'm using Laravel's file storage functionality to save a file: public function dataPost(Request $request) { $fileInForm = 'doc'; if ($request->hasFile($fileInForm)) { $file = $request->file($fileInForm); if ($file->isValid()) { // Filename is hashed filename + part of timestamp $hashedName = hash_file('md5', $file->path()); $timestamp = microtime() * 1000000; $newFilename = $hashedName . $timestamp . '.' . $file->getClientOriginalExtension(); Storage::disk('local')->put($newFilename, $file); } } } This does save the file, but inside a directory named the same as the file, for example: storage

How to use web and api guards at the same time in Laravel?

不想你离开。 提交于 2019-12-04 22:43:29
I have build application with two parts: RESTful part for mobiles and web. How can I use web/api guards at the same time? That I can register users with stadart web form, and accept request like as Restful? Protect whatever routes are for your api with auth:api middleware Route::group(['middleware' => ['auth:api']], function(){ //protected routes for API }); We must make sure that your users table has an api_token column: php artisan make:migration alter_users_table_add_api_token_column Then inside of the up function: Schema::table('users', function($table){ $table->string('api_token', 60)-

Call to undefined method Illuminate\\Database\\Query\\Builder::notify()

筅森魡賤 提交于 2019-12-04 22:20:19
Issue in Laravel 5.3.6 when submitted request in Forgot Password. Error Details Call to undefined method Illuminate\Database\Query\Builder::notify() Issue is in below file: vendor\laravel\framework\src\Illuminate\Auth\Passwords\PasswordBroker.php Line 69. Code is below $user->sendPasswordResetNotification( $this->tokens->create($user) ); Function: sendResetLink It was working fine in Laravel 5.2 and seems not working in 5.3.6 version. Have you faced this issue? Bestmomo Momo You must add Illuminate\Notifications\Notifiable trait in User model. Add the Notifiable trait in your User mode.

fetching data before changing route with react-router

邮差的信 提交于 2019-12-04 19:35:48
I'm using react , react-router , and redux with laravel on the backend and I'm using all the latest releases and I'm actually quite new to these, I just decided I should take my development experiences to the next level and decided to use these based on how I liked them, A LOT . I have the following problem: When I am in the about-us route, I then click Home but before router renders the home page , it needs to make an async call to the server. I notice that I theoretically need this to be async because it needs to finish before proceeding to the next route. Then, I want to have a bar on the

What is the difference between laravel method vs trait vs facade [closed]

本小妞迷上赌 提交于 2019-12-04 17:41:59
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 2 years ago . In a nutshell what would be the easiest way to compare the three? method vs trait vs facade Cheers! They don't really compare because they're really different things. A method is a function that belongs to a class. class MyClass { public function this_is_a_method() { } } A trait is a means of sharing code between classes. A trait cannot be instantiated, but rather is included

Laravel Scheme Builder is adding auto_increment to all integer fields which makes it fail

别说谁变了你拦得住时间么 提交于 2019-12-04 17:29:57
When I try to use PHP Laravels Database Migration and schema builder I keep getting the error below on any tabvle that has an auto incrementing ID column and a regular user_id integer column. The error below shows that the user_id column SQL is being generated with the value auto_increment on the user_id and my code does not tell it to do that anywhere! I am using Laravel v5.3 My schema code is: public function up() { Schema::create('bookmark_tag_lists', function(Blueprint $table) { $table->increments('id', 10); $table->string('title', 100)->nullable(); $table->string('slug', 100)->nullable();

Laravel 5.3 Validation Fails when Variables are Null

怎甘沉沦 提交于 2019-12-04 16:46:54
问题 Since upgrading laravel from 5.1 to 5.3, I've got couple of odd issues with Validation. When I post a data like this: firstName null And the validation rules are like this: $validator = Validator::make($postData, [ 'firstName' => 'string|max:255', 'lastName' => 'string|max:255' ]); The above fails with the messages something like "The XYZ must be a string." . What I don't understand is: Why is the validation failing when it is not set as required ? Meaning, it should ignore it and not throw

api or web Laravel 5.3

故事扮演 提交于 2019-12-04 16:05:57
问题 I have a question that might sound silly to you so please forgive me. I am not sure when do I use the routes/api.php file. If I want to delete a record from a datatable with ajax, do I need to create a separate controller and put the route in api.php or can I use the same controller I use for everything else and put the route in web.php? 回答1: I'm not sure if you read the Laravel documentation or how much familiar you are with Laravel, but in Laravel 5.3 you have web routes and api routes in