laravel-5.3

How can I make sub query in laravel eloquent?

时光怂恿深爱的人放手 提交于 2019-12-02 09:33:14
When I use db raw, it works My query is using db raw like this : $products = DB::select(DB::raw('SELECT * FROM ( SELECT a.*, b.name AS store_name, b.address FROM products a JOIN stores b ON b.id = a.store_id WHERE a.category_id = '.$category_id.' ORDER BY a.total_sold DESC, a.updated_at DESC LIMIT '.$num.' ) AS product GROUP BY store_id')); It works. But I want to change it use laravel eloquent I try like this : $products = Product::where('category_id', '=', $category_id) ->with('store') ->groupBy('store_id') ->orderBy('total_sold','desc') ->orderBy('updated_at', 'desc') ->take($num) ->get();

How can I use lang class laravel in vue.js 2?

。_饼干妹妹 提交于 2019-12-02 08:48:25
My vue component like this : <template> <ul class="nav nav-tabs nav-tabs-bg"> <li role="presentation" v-for="item in tabs"> 1. failed -> {{ item.name }} 2.success -> {{trans('purchase.payment.tab')}} </li> </ul> </template> <script> export default { data() { return { tabs: [ {name: "trans('purchase.payment.tab')"} ] } } } </script> My lang in laravel(resources/lang/en/purchase.php) like this : <?php return [ 'payment' => [ 'tab' => 'Payment Status', ], ... ]; If the component vue executed, the result like this : failed -> trans('purchase.payment.tab') 2.success -> Payment Status So, if trans

How to solve route not defined in laravel 5.3?

久未见 提交于 2019-12-02 08:46:14
My controller code is like this : public function store(CreateUserRequest $request) { $input = $request->all(); $user = $this->userRepository->create($input); Flash::success('User saved successfully.'); return redirect(route('user.index.'.$input['year'])); } There is exist error like this : InvalidArgumentException in UrlGenerator.php line 314: Route [users.index.2016] not defined. When error, the url look like this : http://localhost/mysystem/public/users My routes\web.php is like this : Route::get('users/index/{year}', 'UserController@index')->name('users.index.year'); Route::get('users

Installation error on Laravel 5.3

浪尽此生 提交于 2019-12-02 08:10:09
I am trying to launch laravel which is locally hosted on my browser but it gives me the following error Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /opt/lampp/htdocs/projects/larawiz/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 475 How can I correct this? Your problem is your version of PHP which I believe you may be using PHP 5.5. Laravel 5.3 uses the splat operator which is only available in PHP version 5.6 The line you're referring to is : https://github.com/laravel/framework/blob/5.3/src/Illuminate/Foundation/helpers.php

Why wheredate not working in laravel 5.3?

十年热恋 提交于 2019-12-02 07:59:17
My laravel eloquent is like this : public function search(Request $request) { $search = ''; $searchdate = '2017-04-27'; $reports = Report::whereHas('user', function($query) use ($search) { $query->where(function ($q) use($search) { $q->where('name' ,'LIKE' ,'%'.$search.'%'); }); })->orWhereHas('store', function($query) use ($search){ $query->where(function ($q) use($search) { $q->where('name', 'LIKE', '%'.$search.'%'); }); })->orWhereHas('category', function($query) use ($search) { $query->where(function ($q) use($search) { $q->where('name', 'LIKE' , '%'.$search.'%'); }); })->whereDate(

I want to get user id in laravel 5.3 controller with Auth::user()->id but it creates error their

荒凉一梦 提交于 2019-12-02 07:50:54
I have created a points table and there users points will be debited credited. the structure is like following. id userid p_add p_less description created_at updated_at 1 9 3000 0 purchased -time- -time- 2 9 0 300 expend -time- -time- and I am using following controller code. public function account_page(){ $points = Points::select(DB::raw("sum(p_add)-sum(p_less) as Total"))->where('user_id', 9)->first(); return view('mop.account-page', array('points'=>$points)); } so in view page named as account page result is correctly displayed as I want. But this query is getting user_id as a static value

OAuth2 Grant Type Password is Revoking other access_token

半腔热情 提交于 2019-12-02 05:37:07
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 grant_type password. I can log in only on one device or browser at a time. I'm confused which one is

Updating One to many relation in laravel 5.3

白昼怎懂夜的黑 提交于 2019-12-02 04:28:54
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 $request){ for($i = 1; $i <= $sizeCounter; $i++){ $selectedSize = "size_$i"; if($request->$selectedSize){

hasMany relationship issue in Laravel 5.3 + MongoDB library 'jenssegers/laravel-mongodb'

≡放荡痞女 提交于 2019-12-02 03:45:55
问题 I am using MongoDB library in Laravel 5.3 . I have two collections in MongoDB and I want to make a hasMany relation b/w them. MongoDB: 1st Collection: Employee { "_id" : ObjectId("586ca8c71a72cb07a681566d"), "employee_name" : "John", "employee_description" : "test description", "employee_email" : "john@email.com", "updated_at" : "2017-01-04 11:45:20", "created_at" : "2017-01-04 11:45:20" }, { "_id" : ObjectId("586ca8d31a72cb07a6815671"), "employee_name" : "Carlos", "employee_description" :

Laravel 5.3 Custom Path for Post-authentication Redirect

♀尐吖头ヾ 提交于 2019-12-02 03:13:07
I have two types of users: "vendors" and "clients". And I'm currently using Laravel's built-in Auth Controllers (from the make:auth command) to do my client user authentication. And since I have two kinds of users, I have changed the $redirectTo property on the LoginController , RegisterController , and ResetPasswordController to /client/home . Here is proof: RegisterController LoginController Now, it redirects to /client/home every time I successfully do registration, login, and password reset. But the problem is when I'm in mysite.com/client/home already, whenever I would try to go to mysite