laravel-5.1

Laravel 5 - Load views blade file from storage folder

牧云@^-^@ 提交于 2019-12-23 14:21:14
问题 Is it possible to load views from storage folder instead from resources\views ? 回答1: Yes, you have a couple of choices. 1. Add another path to your view config file Open up config/view.php and add your new path to the paths array: 'paths' => [ storage_path(), realpath(base_path('resources/views')), ], Laravel will return whichever view that matches first, so be sure to sort the paths accordingly. 2. Add a view namespace Open up app/Providers/AppServiceProvider.php and add your new view

Laravel one session per user

*爱你&永不变心* 提交于 2019-12-23 12:55:55
问题 I'm trying to figure out how to only allow one session per user. So if someone tries to log in when he already logged in his user account, the first session will be destroyed and will be logged out to allow the current session only. I'm following this: How to keep single session per user in Laravel . But i don't know where I should put these lines of codes: /** * Swap a user session with a current one * * @param \App\User $user * @return boolean */ protected function swapUserSession($user) {

How to get the current console command in Laravel

∥☆過路亽.° 提交于 2019-12-23 12:38:25
问题 I can see if a script is running in the console with the App::runningInConsole() command, but I would like to know (for audit logging purposes) which command has been run from console. To add some context - I need to log whenever a system or user accesses a certain type of data. For users, that's pretty simple - I can use Auth::user() and get their IP address from Request , but for console commands, it's a little more difficult. I can figure out if a console command is running, which is good,

Laravel hasMany detach

£可爱£侵袭症+ 提交于 2019-12-23 07:56:52
问题 I am having an issue with Eloquent regarding removing child model: When this is executed in process2() I still have the deleted model which is not ok. Model namespace App\Models; use Illuminate\Database\Eloquent\Model; class Model1 extends Model { public function seasons() { return $this->hasMany('App\Models\Seasons', 'series_id', 'id'); } } Service class Process { public function process1($model1Instance) { for($model1Instance->seasons() as $season) { if(//whatever//) { $season->delete(); }

Database [] not configured Laravel 5

烂漫一生 提交于 2019-12-23 07:37:01
问题 I create new db in phpmyadmin and new tables. Then i do public function next(Request $request){ $langs = DB::connection('mydb')->select('select * from lang'); } and get Database [compgen] not configured. in my .env DB_HOST=localhost DB_DATABASE=test DB_USERNAME=root DB_PASSWORD=123 in my config/database.php 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'test'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD'

Alternatives of Join in MongoDB

╄→гoц情女王★ 提交于 2019-12-23 06:56:14
问题 I am new in mongoDB. I am facing Problem with mongoDB. That is " How do i give relationship between two collections in mongoDB? " I read manual of mongoDB that mention mongoDB is not a RDBMS and mongoDB is not support Any kind of JOINS. But i want to know Alternatives of JOINS in mongoDB. 回答1: From MongoDb v3.2 , new $lookup operator was introduced to perform joins in MongoDb . This works as sql left join and its documentation can be found at https://docs.mongodb.com/master/reference/operator

Customize Authentication in Laravel [closed]

人走茶凉 提交于 2019-12-23 06:10:47
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I'm using Laravel 5.1, and I need to use existing user table that has its own password algorithm. After hours and hours of research, I've found solution and here are the steps. Hope this helps Laravelers. 回答1: in config/auth.php file, set driver value to custom. like this. ... 'driver' => 'custom',

Image dose not move at folder path

眉间皱痕 提交于 2019-12-23 05:13:45
问题 I already given 777 permission to my images folder. Charts Table is also saving all record of image. I am going to attach table: charts structure here. public function store(Request $request) { $input = $request->all(); $tradeID= Auth::user()->trade()->create($input); if($file = $request->file('file')) { $name = time() . $file->getClientOriginalName(); $file->move('images', $name); $photo = Chart::create(['file'=>$name]); $input['photo_id'] = $photo->id; } $tradeID->chart()->create($input); }

Multiple middleware has permittion on same routes

自作多情 提交于 2019-12-23 04:53:34
问题 I have multi middleware (studen, parent, admin) and create some route group with that middleware. But some route can access if user is in any of that groups and belong in any of that middleware but not if is in other middleware fot example teacher. I use something like that in docs: http://laravel.com/docs/5.1/routing#route-groups But it's work when I put one route, when add another route group with another middleware it doesn't work. Is that possible and how to make it? When I execute php

Saving multiple data dynamic form in Laravel 5.1 and Vue JS

假装没事ソ 提交于 2019-12-23 04:47:11
问题 I have to add/post data form. But the form dynamically can increase as user 'click' on a button. I've already browse about it and there some answer i get like using $request->all() to fetch all data from input forms. And then my problem is, my app using VueJS as front-end. Is there any some configuration on VueJS script to post all data from that dynamic form?? My Blade template that will be increase dynamically: <div id="form-message"> {!! Form::text('rows[0][DestinationNumber]', null, [ 'id