laravel-5.3

Updating One to many relation in laravel 5.3

两盒软妹~` 提交于 2019-12-20 04:37:09
问题 I want to update a one to many relationship. For example I have a model called Product class Product extends Model { protected $primaryKey = 'product_id'; public $timestamps = FALSE; public function Size(){ return $this->hasMany('App\Size'); } } and a model called Size class Size extends Model { public $timestamps = FALSE; protected $fillable = ['product_id','size']; public function Product(){ return $this->belongsTo('App\Product'); } here is my controller: public function update(Request

OAuth2 Grant Type Password is Revoking other access_token

烂漫一生 提交于 2019-12-20 04:15:42
问题 I've been trying to learn some server side frameworks these days. I am not an expert of oauth2, but I had use an api with a team. They gave me an access using Resource owner credentials grant, with a grant_type as password, client_id and client_secret. I can log in on multiple browsers at the same time. As I have tried sails js oauth 2 and laravel passport oauth2. I got confused. Both of them using grant_type password revoke my old access_token. Using laravel passport and sails js oauth2 with

Laravel 5 How to validate a unique customer name under each Activity when save

我是研究僧i 提交于 2019-12-20 03:52:36
问题 I had three model: Activity Model, Customer Model and Customeritem Model How to do the validation checking in store function whereby the customer name should be UNIQUE in each Activity? Below is each migration files Activity Model public function up() { Schema::create('activities', function (Blueprint $table) { $table->increments('id'); $table->string('activityName'); $table->string('activityCode'); $table->string('activityVenue'); $table->timestamps(); }); } Customer Model public function up

Laravel Config::set Persist Through Requests?

柔情痞子 提交于 2019-12-20 03:25:11
问题 I have been building a web application that tracks statistics. These statistics can range between different companies. I decided to use a main database to house all of the login credentials and each company gets a separate database to themselves. After the user logins in they will be redirected to this function... /** * Redirects the user to the appropriate sub link */ public function redirect() { Config::set('database.connections.club.database', Auth::user()->club->db_name); if (Auth::user()

Module not found: Error: Can't resolve 'fs'

蹲街弑〆低调 提交于 2019-12-20 01:03:47
问题 I working on a Laravel 5.3 project. I am getting below errors when I am running gulp command in CMD. Could anyone say how can I get a error less result ? gulpfile.js var elixir = require('laravel-elixir'); require('laravel-elixir-vue'); elixir(function(mix) { mix.sass('app.scss'); }); elixir(function(mix) { mix.webpack('app.js'); }); elixir(function(mix) { mix.version(['css/app.css', 'js/app.js']); }); package.json { "private": true, "scripts": { "prod": "gulp --production", "dev": "gulp

Laravel global middleware can't get session

不想你离开。 提交于 2019-12-19 21:19:51
问题 protected $middleware = [ \App\Http\Middleware\Syspoint::class, ] use Session; class Syspoint { echo \Session::get('syspoint'); } I have a middleware required run everytime when page request, the middleware contain session. I place inside of protected $middleware , but global middleware not able to get session. 回答1: You are calling Session but it is not already started. If you need Session inside your middleware you have to put it in the property protected $middlewareGroups under the key web

Laravel 5.3: How to use Auth in Service Provider?

不问归期 提交于 2019-12-19 11:27:07
问题 I am passing a value in shared view by taking value from table. I need to know user ID for the purpose but Auth::check() returns false. How do I do it? Below is code: public function boot() { $basket_count = 0; if (Auth::check()) { //always false $loggedin_user_id = Auth::user()->id; $basket_count = Cart::getBasketCount(); } view()->share('basket_count', $basket_count); } 回答1: OK turns out that ServiceProviders are not place for such things. The best thing is a Middleware . So if you want to

Laravel change Connection for Notifications table

戏子无情 提交于 2019-12-19 09:52:41
问题 I am implementing Laravel 5.3 Notifications at the moment which is working very nice. At the moment I am using 'email' as a notifications channel but I want to add 'database' too. I am using different databases/connections for languages and want to store the notifications in a central database / Connection. How do I use a different database connection for notifications? I already tried creating a Notifications model but that did not work: namespace App; use Illuminate\Database\Eloquent\Model;

vue-router in conjunction with laravel routes

。_饼干妹妹 提交于 2019-12-19 09:24:21
问题 I have setup vue-router successfully but I have some problem mixing it with my laravel 5.3 routes. I have a php route for home: Route::get('/', array('as' => 'home', 'uses' => 'HomeController@showWelcome')); and I have setup vue-router routes: '/user-feed': { name: 'user-feed', title: 'User Feed', component: Feed }, '*': { component: PageNotFound } In my web.php route file, I have the following: Route::get('/', array('as' => 'home', 'uses' => 'HomeController@showWelcome')); // use vue-router

PostTooLargeException in ValidatePostSize.php line 22 laravel

China☆狼群 提交于 2019-12-19 07:25:27
问题 I am trying to upload a form containing images too. When I submit it. it shows this error PostTooLargeException in ValidatePostSize.php line 22: How do I resolve this issue? 回答1: Check the following parameters in your php.ini file. I've had this issue on several occasions and it's usually because the max_file_size is set to 2M by default. max_file_size upload_max_filesize post_max_size **Edit I was asked how to validate file size using the validate method in Laravel before the file is sent to