laravel-5.3

Laravel Passport Scopes

不问归期 提交于 2019-11-27 03:12:26
I am a bit confused on the laravel scopes part. I have a user model and table. How can I assign a user the role of user, customer and/or admin. I have a SPA with vue and laravel api backend. I use https://laravel.com/docs/5.3/passport#consuming-your-api-with-javascript Passport::tokensCan([ 'user' => 'User', 'customer' => 'Customer', 'admin' => 'Admin', ]); How can i assign which user model has which scope(s)? Or are scopes not the same as roles? How would you implement this? Thanks in advance! Or are scopes not the same as roles? The biggest difference between the two is the context they

Call to undefined method Illuminate\Database\Query\Builder::lists() when seeding after updating to Laravel 5.3

主宰稳场 提交于 2019-11-27 02:30:29
问题 I'm updating to laravel 5.3, and I get this message: [2016-08-23 23:12:39] local.ERROR: BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::lists() in /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2431 Stack trace: #0 [internal function]: Illuminate\Database\Query\Builder->__call('lists', Array) #1 /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1423): call_user_func_array(Array,

How to add dynamic dropdown list column on Laravel 5.3 registration?

核能气质少年 提交于 2019-11-27 02:12:24
I want to create a dropdown list where the data retrieved from the database, ie dropdown level. the value of the dropdown level is taken from the table level. My register controller is like this : <?php namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\RegistersUsers; class RegisterController extends Controller { use RegistersUsers; protected $redirectTo = '/home'; public function __construct() { $this->middleware('guest'); } protected function validator(array $data) { return Validator::make($data, [ 'name' =>

Adding Access-Control-Allow-Origin header response in Laravel 5.3 Passport

余生长醉 提交于 2019-11-27 00:19:46
I'm new to Laravel and am doing some Laravel 5.3 Passport project with OAuth2.0 password grant. When I curl the API with the params it responds with token. However, in browser it needs an additional security that the endpoint should add because my request is coming from localhost while the API is located in my VM. Here's the error: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 400. I know what the issue is but I don't know where to put to include that header since

How can I solve incompatible with sql_mode=only_full_group_by in laravel eloquent?

落花浮王杯 提交于 2019-11-26 23:20:17
问题 My laravel eloquent is like this : $products = Product::where('status', 1) ->where('stock', '>', 0) ->where('category_id', '=', $category_id) ->groupBy('store_id') ->orderBy('updated_at', 'desc') ->take(4) ->get(); When executed, there exist error like this : SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'myshop.products.id' which is not functionally dependent on columns in GROUP BY clause; this

How to add some textfield in form register (laravel generator infyom)?

痴心易碎 提交于 2019-11-26 23:19:46
I read the tutorial here : http://labs.infyom.com/laravelgenerator/docs/5.3/installation I clone the admin lte generator : https://github.com/InfyOmLabs/adminlte-generator/tree/5.3 I access it in my localhost. The register form like this : https://postimg.org/image/5gswtx4gn/ I want to add some text field and combo box. eg, level, level, username etc When I access the code, I'm confused The code is like this : Controller register is like this : <?php namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth

Laravel 5.3 auth check in constructor returning false

房东的猫 提交于 2019-11-26 22:51:55
I'm using Laravel 5.3 and I'm trying to get the authenticated user's id in the constructor method so I can filter the user by assigned company as follows: namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Support\Facades\View; use App\Models\User; use App\Models\Company; use Illuminate\Support\Facades\Auth; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs,

How to pass laravel CSRF token value to vue

时光毁灭记忆、已成空白 提交于 2019-11-26 22:48:00
问题 I have this form where the user should only type text inside a text area: <form action="#" v-on:submit="postStatus">{{-- Name of the method in Vue.js --}} <div class="form-group"> <textarea class="form-control" rows="5" maxlength="140" autofocus placeholder="What are you upto?" required v-model="post"></textarea> </div> <input type="submit" value="Post" class="form-control btn btn-info"> {{ csrf_field() }} </form> Then, I have this script code where I am using vue.js with ajax in order to

How to display button link with vue.js?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 22:27:57
问题 My view is like this : <div class="panel panel-default panel-store-info"> ... <div id="app"> <AddFavoriteProduct></AddFavoriteProduct> </div> .... </div> My component is like this : <template> <a href="javascript:" class="btn btn-block btn-success" @click="addFavoriteProduct({{ $product->id }})"> <span class="fa fa-heart"></span> Favorite </a> </template> <script> export default{ name: 'AddFavoriteProduct', props:['idProduct'], methods:{ addFavoriteProduct(event){ event.target.disabled = true

Laravel 5.3 withCount() nested relation

倾然丶 夕夏残阳落幕 提交于 2019-11-26 20:52:09
问题 The model structure is as follows Tutorial -> (hasMany) Chapters -> (hasMany) videos How can we load number of videos (video_count) from Tutorial Model with laravel 5.3's withCount() method I have tried: Tutorial::withCount('chapters') ->withCount('chapters.videos') // this gives error: Call to undefined method Illuminate\Database\Query\Builder::chapters.videos() ->all(); Edit This works, Any Better solution? Tutorial::withCount('chapters') ->with(['chapters' => function($query){ $query-