laravel-5.2

Laravel - Implicit route model binding with soft deleted data

怎甘沉沦 提交于 2020-01-04 04:34:06
问题 I am having a small issue. There are two user roles and one is a normal member and one is an admin. The member can delete a blog and they will not be able to see the blog after they delete (soft delete) it while the admin can still see the blog, even if it's soft deleted. Example code: // Route file Route::get('/blog/{blog}', 'BlogController@show'); // BlogController public function show(App\Blog $blog) { // It never gets to here if the blog has been soft deleted... // Automatically throws an

Command “clear-compiled” is not defined. Laravel 5.2

你说的曾经没有我的故事 提交于 2020-01-03 15:24:46
问题 I am trying to download Laravel HTML dependencies with Composer. composer.json is here: "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.5.9", "laravel/framework": "5.2.*", "illuminate/html": "5.2" }, And when I run composer update or php composer update , the terminal log is: E:\xampp\htdocs\lara-test>composer update > php artisan clear-compiled [InvalidArgumentException]

Authentication using multiple tables in Laravel 5.2

荒凉一梦 提交于 2020-01-03 04:35:13
问题 I am trying to create a laravel application with version 5.2. Where there will be 3 types of users Administrator (website manager) - using default " users " table for this. Owners (Website listing creator from frontend) - using a table " owners " for this. Customer (Visitors or registered visitors) - using a table " customers " for this. Now my problem is: i want to make sure login Owners will get proper authentication and redirect to their own (other then default Auth route) route. And same

Laravel 5.2 Custom validation message with custom validation function

我是研究僧i 提交于 2020-01-03 04:28:07
问题 I want to create custom validation rule with custom validation error message. For this I created a rule: $rule => [ 'app_id' => 'isValidTag' ] And for custom message: $message => [ app_id.isValidTag => 'Not a Valid id' ]; After that I created Service Provider: class CustomValidationServiceProvider extends ServiceProvider { public function boot() { //parent::boot(); $this->app->validator->resolver(function($transator,$data,$rules,$messages){ return new CustomValidator($transator,$data,$rules,

Eager Loading, Constraining Eager Loads, Lazy Eager Loading

允我心安 提交于 2020-01-02 22:02:12
问题 I'm learning Laravel, and I'm using Laravel 5.2. I want to know about Eager Loading, Constraining Eager Loads, and Lazy Eager Loading. What are the similarities and differences between those three? Can you give an example for each of them? I have read Laravel documentation, but I still don't understand. I hope you can give clearer explanation. Thanks. 回答1: Nutshell: Eager Loading allows you to get the relationships for some Models efficiently. Constraining Eager Loads Again makes it efficient

Get online users in laravel

♀尐吖头ヾ 提交于 2020-01-02 07:49:09
问题 I have one user for login to demo of my script. I want get how many people online now. I use laravel 5.2 What am I do? 回答1: You could keep sessions in a DB and use last_activity column to determine how many users are currently online. https://laravel.com/docs/5.1/session#introduction 回答2: There is a laravel plugin to achieve this. here's the link :https://github.com/thomastkim/laravel-online-users 回答3: you can use the below package in order to get online users or determine if a user is online

Laravel Resource destroy via ajax

↘锁芯ラ 提交于 2020-01-02 07:26:09
问题 Can I use resource via ajax? I have this resource Route::resource('dashboard', 'DashBoardController'); js file $.ajax({ type: 'delete', dataType: 'json', data: {id:id}, url: " {!! route('dashboard.destroy') !!} ", success: function (data) { // } }); but I receive, NotFoundHttpException in RouteCollection.php line 161: 回答1: A destroy method is using a DELETE request , but it actually uses POST request within an _method as parameter, so your javascript section should looks like this: $.ajax({

Conflict database when Multiple Laravel Projects on single machine or laravel not reading .env file

我只是一个虾纸丫 提交于 2020-01-02 03:49:13
问题 I am using xampp on windows 10. I have multiple laravel 5.2 projects on this machine. When I am executing Project 1 it gives me the error that database_project_1.table_of_project_2 table or view do not exist, but the table table_of_project_2 is existing in the database_project_2 . This issue comes rarely. Below is the Project 1 .env file APP_ENV=local APP_DEBUG=true APP_KEY=base64:ratSluNv930gb3wp1UOabW6Ze3jEJn3ixtTX/wgqYZc= APP_URL=http://project-1.dev/ DB_CONNECTION=mysql DB_HOST=127.0.0.1

User Auth not persisting within Laravel package

Deadly 提交于 2020-01-02 02:40:08
问题 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(

Laravel 5.2 auth change 'id' to 'customer_id'

最后都变了- 提交于 2020-01-02 02:02:06
问题 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' => [