laravel-5.2

How to use global prefix for tables in Laravel 5

随声附和 提交于 2019-12-05 10:11:49
New in Laravel. Probably a silly question. I had setup database like this: 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'), 'database' => 'mydb', 'username' => 'myusername', 'password' => 'mypassword', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'admin', 'strict' => false, 'engine' => null, ], Notice 'prefix' => 'admin' . This is because I want all tables related to the website's control panel be prefixed with admin , e.g: admin_users, admin_log, etc... But I'm stuck at the very beginning. I'm trying to create

Class App\\Http\\Controllers\\AuthController does not exist Laravel 5.2

余生颓废 提交于 2019-12-05 08:15:49
My whole application, made in Laravel 5.2, is working perfectly fine but when i tried to get list of routes through following command: php artisan route:list It shows me following error: [ReflectionException] Class App\Http\Controllers\AuthController does not exist i tried to add namespace aswell: Route::group(['middleware' => ['web'], 'namespace' => 'Auth'], function () { Route::auth(); }); then it shows me following error: [ReflectionException] Class App\Http\Controllers\Auth\Auth\AuthController does not exist My routes file is: Route::group(['middleware' => ['web'], 'namespace'=>'Auth'],

WebSocket with Laravel 5.2

两盒软妹~` 提交于 2019-12-05 07:48:41
问题 I'm doing a aplication in Laravel 5.2 that uses websockets. For the websocket connection I'm using HoaServer, wich works very well. The bad part is, I do not know how to make this server as a controller, or at least have acess to my models, right now I'm using a separeted PDO connection to make the DB querys. Someone knows if it is possible to make this server as a controller or at least have acess to the database throught laravel models? My server right now: require_once(__DIR__.'/../vendor

query that worked in Laravel 5.2 give me error in Laravel 5.3

只谈情不闲聊 提交于 2019-12-05 06:16:32
This query works in 5.2: $galleries = Gallery::with(array( 'images' => function ($query) { $query->orderBy('order', 'asc'); } )) ->with('votes') ->leftJoin('votes', 'votes.votable_id', '=', 'gallery.id') ->selectRaw( 'gallery.*, count(case votes.status when "upvote" then 1 else null end) - count(case votes.status when "downvote" then 1 else null end) as points' ) ->where('votes.votable_type','App\Gallery') ->groupBy('gallery.id') ->orderBy('points', 'desc') ->published()->orderBy('gallery.created_at', 'desc')->paginate(30); I am trying to select all galleries that have votes, when I run this

Laravel 5.2 Event Testing: expectsEvent not seeing the event fired although it is being fired

余生颓废 提交于 2019-12-05 05:36:48
I have been trying to test events and I had it working yesterday. That was before I started to refactor the test code to keep it from being too repetitious. I added the setUp method call to generate the fake data using ModelFactories. This was done in each test case yesterday and as stated it was working. I am thinking it has something to do with using the setUp method but I have no idea why that would be the case. First I attempted to use setUpBeforeClass() static method as that is only run once on unit test runs. However the laravel application is not actually setup until the first call to

User Auth not persisting within Laravel package

强颜欢笑 提交于 2019-12-05 04:20:49
This is my first attempt at a laravel package and have run into an issue where Auth::attempt($credentials) works within my login controller, but upon redirection to a protected route or controller, the user is no longer authenticated. Below is my login controller method with the redirect to dashboard commented out. public function attempt(Request $request){ $email = strtolower(strip_tags(htmlspecialchars($request->input('email')))); $password = strip_tags(htmlspecialchars($request->input('password'))); if (Auth::attempt(array('email' => $email, 'password' => $password))) { // Redirect to

Exclude route from Laravel authentication

不想你离开。 提交于 2019-12-05 04:04:21
After running php artisan make:auth all the required routes are in the route.php file, but is it possible to remove one (I want to remove the register route)? Currently I have Route::group(['middleware' => 'web'], function () { Route::auth(); }); I know that Route::auth() is a shortcut to add all the routes. Should I specify the routes myself instead of using the shortcut? Unfortunately you can't exclude register with the current implementation of Route::auth() . You would have to specify all the routes manually so // Authentication Routes... $this->get('login', 'Auth\AuthController

Laravel 5.2 auth change 'id' to 'customer_id'

人走茶凉 提交于 2019-12-05 03:22:59
In this topic I asked a question: Laravel 5.2 auth change 'users' table But now my problem has changed. By default the users table has an id . But I want a customer_id , so I changed everything but it don't work. It keeps asking for an id . SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from klanten where id = 1 limit 1) In the table klanten I have a customer_id , but it keeps asking for an id . Things I've changed: config/auth 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, 'table' => 'klanten', ], created a

Laravel 5.2 Intervention Image 500 Server Error

∥☆過路亽.° 提交于 2019-12-05 03:21:49
When I upload big images (4.2 MB) Intervention Image is throwing 500 Error... private function resizeImage($path, $imgName){ $sizes = getimagesize($path.$imgName); if($sizes[0] > $sizes[1]){ ImageManagerStatic::make($path.$imgName)->fit(920,474)->insert(public_path() . "/uploads/applications/watermark.png",'bottom-right', 30, 30)->save($path."1_".$imgName); }else{ ImageManagerStatic::make($path.$imgName)->heighten(474)->insert(public_path() . "/uploads/applications/watermark.png",'bottom-right', 30, 30)->save($path."1_".$imgName); } ImageManagerStatic::make($path.$imgName)->fit(440,226)->save(

Pluck with multiple columns?

陌路散爱 提交于 2019-12-05 02:44:38
When i use pluck with multiple columns i get this: {"Kreis 1 \/ Altstadt":"City","Kreis 2":"Enge","Kreis 3":"Sihifeld","Kreis 4":"Hard","Kreis 5 \/ Industriequartier":"Escher Wyss","Kreis 6":"Oberstrass","Kreis 7":"Witikon","Kreis 8 \/ Reisbach":"Weinegg","Kreis 9":"Altstetten","Kreis 10":"Wipkingen","Kreis 11":"Seebach","Kreis 12 \/ Schwamendingen":"Hirzenbach" But i need this? ["Rathaus","Hochschulen","Lindenhof","City","Wollishofen","Leimbach","Enge","Alt-Wiedikon","Friesenberg","Sihifeld","Werd","Langstrasse","Hard","Gewerbechule","Escher Wyss","Unterstrass","Oberstrass","Fluntern",