laravel-5.4

Laravel: Load more data from controller into view

泪湿孤枕 提交于 2020-02-02 16:11:28
问题 i would like to ask how can i display more data by using js or ajax and call Controller displaying the result into my view. Until now i 'm displaying 8 posts with limit(8) for the first time. Then i 'm using ajax to call the controller and bring each time more 8 posts. The problem i 'm facing is that the posts are the same each time i call the controller or the ajax. This is my PostsController class PostsController extends Controller { public function index(Request $request) { $posts = Post:

Display own post only and all posts for admin in laravel

a 夏天 提交于 2020-01-25 01:01:07
问题 I'm trying to display all posts which are added to admin and only own posts to the logged user. This is what I've trying in my controller public function index(Request $request) { $items = Item::where('author_id', Auth::user()->id)->orderBy('id','DESC')->with('author')->paginate(5); return view('items.index',compact('items')) ->with('i', ($request->input('page', 1) - 1) * 5); } In the models I have this relations. Item model: public function author() { return $this->belongsTo(User::class); }

404 Not Found, but route exist in Laravel 5.4

≯℡__Kan透↙ 提交于 2020-01-24 02:06:18
问题 I'm using PhpStorm. I can run and open the index.php , but when I want to press submit button (post sign in), its display 404 not found. Web server Apache 2.4 running on Windows 10. This is my home This is my route 回答1: I'm not entirely sure why all the down-votes, especially since this is a common issue and the cause can be hidden for someone new to the Laravel environment. I know this is an old post, but I add it here for future newbies. The first thing I suggest trying is running php

Laravel 5 multiple optional parameters in route

浪尽此生 提交于 2020-01-23 08:37:50
问题 I have a problem with Laravel 5, and to be precise, I can't find the solution for it. In C# (ASP.NET MVC) it's easy to solve. For example, I have these routes (I'll just type the route content, and the function header, for the sake of simplicity) /{category}/Page{page} /Page{page} /{category} The function is defined inside Product controller. function header looks like this: public function list($page = 1, $category = null) the problem is, whenever I enter just one argument, it doesn't send

how to get all the headers information in laravel 5.4

Deadly 提交于 2020-01-23 05:44:45
问题 when i print like: echo '<pre>'; print_r(getallheaders()); it gives output [Host] => abc.com [User-Agent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:51.0) Gecko/20100101 Firefox/51.0 [Accept] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [Accept-Language] => en-US,en;q=0.5 [Accept-Encoding] => gzip, deflate [Cookie] => someth [Upgrade-Insecure-Requests] => 1 [Cache-Control] => max-age=0 [SM_TRANSACTIONID] => 000000000000000000000000b7857360-1499-58b735e6-68944700

How to use bootstrap 4 in Laravel 5.4?

為{幸葍}努か 提交于 2020-01-22 09:42:58
问题 I installed bootstrap 4 using npm on my laravel app. But I think bootstrap 3 working behind not bootstrap 4. using command: npm install npm install bootstrap@4.0.0-alpha.6 Did I left something to do? Or do I need to manually import bootstrap to assets/sass/app.scss file or else? 回答1: You have to manually change the link to bootstrap from resources/assets/sass/app.scss . You will see this line @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; Replace with @import "node

Laravel Passport API Status Code:403 Forbidden

落花浮王杯 提交于 2020-01-17 08:29:12
问题 I am developing an Ionic Mobile App that connects to the server in Laravel via REST API. I used the Laravel passport package and configured some stuffs on how authorization tokens will work on the API. So I write some code on providers for the Ionic app and I have this login function for the user in the mobile to logged in via API from the server but it keeps telling me this error: Status Code:403 Forbidden This seems to be a server side error that I don't have the permission to access this

Laravel Passport API Status Code:403 Forbidden

空扰寡人 提交于 2020-01-17 08:27:06
问题 I am developing an Ionic Mobile App that connects to the server in Laravel via REST API. I used the Laravel passport package and configured some stuffs on how authorization tokens will work on the API. So I write some code on providers for the Ionic app and I have this login function for the user in the mobile to logged in via API from the server but it keeps telling me this error: Status Code:403 Forbidden This seems to be a server side error that I don't have the permission to access this

Laravel 5.4 Internal error: Failed to retrieve the default value

泪湿孤枕 提交于 2020-01-14 07:22:27
问题 I have a form which submits data to the database. And it submits data to the database. But Laravel yields an error when it tries to redirect it to another method in the same controller. ReflectionException in RouteDependencyResolverTrait.php line 57: Internal error: Failed to retrieve the default value Here is the controller I use. Please check the public function store(Request $request) method. <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Inbox; class

Laravel 5.4 - Disable auto login after registration

南楼画角 提交于 2020-01-14 07:20:10
问题 I need to disable auto login after register an user in laravel 5.4 application. There are enough sources [example] for 5.2 and 5.3 version but it is hard find out a solution for 5.4 version. In Laravel 5.4 there is no AuthController as it divided to LoginController and RegisterController . Guide me to disable auto login in laravel 5.4. 回答1: Since your RegisterController uses RegistersUsers trait, all of the trait's methods are available to RegisterController . The method you need to override,