laravel-5.4

eval() in laravel not executing the string

故事扮演 提交于 2019-12-04 22:03:34
My database table contains an eloquent query click here to see Database Table Snapshot .I have fetched the query from database.Now problem is that I'm unable to execute the query that is in the collection. I have Tried eval() to execute the query present the collection.But eval() is not executing it. eval("\"$tempdata\";"); $tempdata contains the query that is in the database table. You need to add return when using eval. Try: eval("return $tempdata;"); Hope this helps! 来源: https://stackoverflow.com/questions/45979813/eval-in-laravel-not-executing-the-string

how to guard a controller through multiple of user?

限于喜欢 提交于 2019-12-04 21:03:26
It is project requirement. where i have multiple logins but some user can not access few module. like super admin and analyst can access all module but developer can only use own controller. so in this case , how can i guard a controller with multiple logins. also note that i have separate login page and table into Database. for Example phonebookController can be access by super admin and analyst but not by developers. so please tell me how can i implement this? i use this for :: if( Auth::guard('superAdmin')->check() ) { $author =Auth::guard('superAdmin')->User()->id ; } else if( Auth::guard(

Laravel - Collection with relations take a lot of time

半世苍凉 提交于 2019-12-04 20:58:41
We are developing an API with LUMEN. Today we had a confused problem with getting the collection of our "TimeLog"-model. We just wanted to get all time logs with additional informationen from the board model and task model. In one row of time log we had a board_id and a task_id. It is a 1:1 relation on both. This was our first code for getting the whole data. This took a lot of time and sometimes we got a timeout: BillingController.php public function byYear() { $timeLog = TimeLog::get(); $resp = array(); foreach($timeLog->toArray() as $key => $value) { if(($timeLog[$key]->board_id && $timeLog

Select all selected id's in a multiselect dropdown in laravel 5.4 with harvest chosen

两盒软妹~` 提交于 2019-12-04 20:36:40
I have a dropdown called designation, where a user can add some information against multiple designation. If I add 1 record against 3 designation, then I need to select those during validation and edit time also. Ex: Choosed id's {5,7,8} from [1 to 10]. <select id="forWhom" name="forWhom[]" multiple class="form-control chosen"> <option value="">--- Select ---</option> @foreach ($desgInfo as $key => $value) <option value="{{ $key }}" {{ old('forWhom',$info->forWhom) == $key ? 'selected' : ''}} />{{ $value }}</option> @endforeach </select> After add of those information I store those selected id

Laravel “Wrong password” error message

好久不见. 提交于 2019-12-04 14:59:57
I'm creating a login function in Laravel 5.4 and I want to show error message in the view when the password is incorrect. Also I have a custom message for account approval so it makes things a bit difficult for me. Meanwhile I put those messages together but is not very user-friendly. How can I separate them? This is my controller: public function login(Request $request) { // validate the form data $this->validate($request, [ 'email' => 'required|email|exists:users,email', 'password' => 'required|min:6' ]); // attempt to log if (Auth::attempt(['approve' => '1', 'email' => $request->email,

Laravel Passport 404

一世执手 提交于 2019-12-04 12:18:51
I installed Laravel Passport using the Laravel docs, the Laravel version is 5.4. Everything worked fine so far now I add these lines into my view: <!-- let people make clients --> <passport-clients></passport-clients> <!-- list of clients people have authorized to access our account --> <passport-authorized-clients></passport-authorized-clients> <!-- make it simple to generate a token right in the UI to play with --> <passport-personal-access-tokens></passport-personal-access-tokens> The Ui looks good, but if I try to add a new Client or Token I get this message: Whoops! Something went wrong!

Select Selected value of a dropdown in laravel 5.4

我们两清 提交于 2019-12-04 09:05:22
I have a dropdown called designation, where a user will select one of it, and after submitting it, if there is some error then I want to select the selected designation. I am using this in laravel 5.4. Controller $info = DB::table("designation") ->where('status','=',1) ->pluck("name","id"); return view('regUser.add',['check' => 'userList','designation' => $info]); View Files <div class="form-group {{ $errors->has('designation') ? ' has-error' : '' }}"> <label for="designation">Designation</label> <select id="designation" name="designation" class="form-control"> <option value="">--- Select

How to integrate Swagger in Lumen/Laravel for REST API?

大城市里の小女人 提交于 2019-12-04 08:37:34
问题 I have built some REST API in Lumen micro framework and it's working fine. Now I want to integrate Swagger into it so the API will be well documented on future use. Has anyone done this? 回答1: Steps to follow for Laravel Lumen 5.7 with swagger using OpenApi 3.0 specs (this governs the way you write annotations so that swagger documentation is generated) I reached this adjusting on @black-mamba answer in order to make it work. 1. Install swagger-lume dependency (which also installs swagger)

How to use Console Kernel in Laravel PHP?

我只是一个虾纸丫 提交于 2019-12-04 07:47:48
I am reading the documentation at Laravel under the heading Architecture Concepts . I am unable to understand application and usage of Console Kernel .(not the Http Kernel) However, I googled out and found these links https://laravel.com/api/5.2/Illuminate/Foundation/Console/Kernel.html https://laravel.com/api/5.3/Illuminate/Contracts/Console/Kernel.html But I can't understand anything with that API ! The HTTP Kernel is used to process requests that come in through the web (HTTP). Website requests, AJAX, that kind of stuff. The Console Kernel is used when you interact with your application

Laravel 5.4 Migration Error

筅森魡賤 提交于 2019-12-04 07:02:33
I am facing a issue that I cannot resolve. I have my app hosted on my server using Ubuntu 16.04, PHP 7.1, MySQL and NGINX. My app works perfect. When I ssh to my server and app root I run the following, php artisan session:table, it runs successfully. When i run php artisan migrate I get foll0wing error and table is not created in my DB. [Illuminate\Database\QueryException] could not find driver (SQL: select * from information_schema.tables where t able_schema = UNIT3D and table_name = migrations) [PDOException] could not find driver Any ideas? Im trying to use this. https://github.com