laravel-5.1

error with migrate refresh

倾然丶 夕夏残阳落幕 提交于 2020-01-07 03:49:25
问题 I am getting this error when trying to run: php artisan migrate:refresh: Rolled back: 2016_02_16_114444_create_posts_table Rolled back: 2016_01_20_234538_expectations Rolled back: 2016_01_20_200616_expectation_profile Rolled back: 2015_12_22_111958_create_profiles_table Rolled back: 2014_10_12_100000_create_password_resets_table Rolled back: 2014_10_12_000000_create_users_table [Illuminate\Database\QueryException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'follower

SUM table in laravel 5

主宰稳场 提交于 2020-01-07 02:02:47
问题 SUM data column total ?for example i have two data in column total 01:45 and 02:25 result must be 4:10 . i have already try but my code only sum the hours not with the minute. what should do ? here my controller. for sum public function getMei() { $data['users'] = DB::table('lembur_karyawan') ->select('nama', DB::raw('SUM(total) as total_lembur')) ->groupBy('nama') ->havingRaw('SUM(total)') ->first(); return view('mei_user', $data); } and my view : <?php echo $users->{'total_lembur'} ?> 回答1:

Laravel 5.1 Create table from controller

被刻印的时光 ゝ 提交于 2020-01-06 19:29:18
问题 This is the situation: I have a list of user, this user are associate to a company and those companies are associate to a group. Each user can create a client who is associate to the user and the company in which the user belong. For the moment, all my client are in the same database table. But I want to have a clients table for each company. I'm looking for the right way to create a clients table when i create a company. Example, when I create company A, the controller add the row A in the

.env and mail.php files won't update - Laravel 5.1

为君一笑 提交于 2020-01-06 19:25:01
问题 I started a project a few months ago and set the configuration to send mail, everything works great. But now i want to change the sender email address, so i changed the configuration in the .env and mail.php files, but laravel just ignored the updates (still uses the old configuration to send mail). I cleared cache and restarted everything, I even deleted those files and laravel keeps sending emails with the deleted files configuration. What can i do? .env: MAIL_DRIVER=smtp MAIL_HOST=smtp

Store/Check/Get/List Cookie in Laravel 5.1

陌路散爱 提交于 2020-01-06 06:50:14
问题 I just store a cookie into the queue Cookie::queue('session', $response['session'], 3); When I try to list all the cookies in the queue, I got an empty array dd(Cookie::getQueuedCookies()); // I got empty array ---> [] if(Cookie::has('session')) { $session = Cookie::get('session'); } What did I miss ? This question is about Cookie and Cookie != Session 来源: https://stackoverflow.com/questions/49801840/store-check-get-list-cookie-in-laravel-5-1

middleware.dev redirected you too many times

拥有回忆 提交于 2020-01-06 05:24:11
问题 I am running laravel version 5.4.26 my localhost project url is : middleware.dev . first time login in this url : middleware.dev/login ,and login successfully completed. Then enter this url : middleware.dev/admin ,then error message bellow This page isn’t working middleware.dev redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS Kernel.php <?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { /** * The

count string length including 'invisible characters' like \r \n in javascript and php

时光总嘲笑我的痴心妄想 提交于 2020-01-06 01:29:49
问题 I am trying to display a "x characters left" text next to a textarea, to see how much still can be written, with javascript / jquery: var area = 'textarea#zoomcomment'; var c = $(area).val().length; Then the input is validated with laravel's max validation. 'comment' => 'required|max:3000' The javascript does not count the \n or \r characters, but PHP/laravel does. Is there a javascript function to count everything , including linebreaks etc ? I'd like to have the same string length with js

Convert Mysql Query to Laravel Eloquent

一笑奈何 提交于 2020-01-05 23:28:22
问题 I am using Laravel 5.1 in my application. My MySQL Query is SELECT * FROM (SELECT uu.*,t.left_id AS meb_id,(CAST(t.pair AS UNSIGNED) - IFNULL(p.pair,0)) AS pair FROM (SELECT left_id, (CASE WHEN ((SELECT COUNT(meb_id) FROM user_count WHERE left_id=u.left_id AND active = 1 AND join_date <= '1442255400000') >= (SELECT COUNT(meb_id) FROM user_count WHERE right_id=u.left_id AND active = 1 AND join_date <= '1442255400000')*2) THEN (SELECT COUNT(meb_id) FROM user_count WHERE right_id=u.left_id AND

Laravel eloquent - get the most recent row when using WhereIn function

倾然丶 夕夏残阳落幕 提交于 2020-01-05 17:37:46
问题 I currently have a function: Score::whereIn('site_id', $sites) ->where('type', 1) ->avg('score'); But at the moment, as you can see, it averages out amongst all results within the Scores table. I want to only average out against the most recent row of each $site_id (the table may not have all $site_id's in the results though). The table has a created_at column, which will determine which is the latest one by date/time. 回答1: Use orderBy('created_at', 'DESC') and limit your result with take(15)

Laravel eloquent - get the most recent row when using WhereIn function

妖精的绣舞 提交于 2020-01-05 17:37:11
问题 I currently have a function: Score::whereIn('site_id', $sites) ->where('type', 1) ->avg('score'); But at the moment, as you can see, it averages out amongst all results within the Scores table. I want to only average out against the most recent row of each $site_id (the table may not have all $site_id's in the results though). The table has a created_at column, which will determine which is the latest one by date/time. 回答1: Use orderBy('created_at', 'DESC') and limit your result with take(15)