laravel-5.3

Class 'SEOstats\SEOstats' not found when calling SEOStats instances in laravel 5.3

南笙酒味 提交于 2019-12-23 20:00:31
问题 I am trying to use SEOstats php package in laravel, I've installed it using composer and then in my controller I have used it like below : use SEOstats\Services as SEOstats; class ReportageController extends Controller { public function store(Request $request) { $url = 'http://www.google.com/'; // Create a new SEOstats instance. $seostats = new \SEOstats\SEOstats; // Bind the URL to the current SEOstats instance. if ($seostats->setUrl($url)) { dd( SEOstats\Alexa::getGlobalRank()); } } } The

How to pass a static variable to a Laravel route?

天大地大妈咪最大 提交于 2019-12-23 19:42:36
问题 I try to rewrite Symfony routes to Laravel routes. The problem is that some Symfony routes take defaults and go the same controller. Can I add some arguments to the Laravel routes to accomplish the same? e.g. Symfony yaml path: /account/ defaults: _controller: "legacy.controller.fallback:Somefunt" pag_act: "secret" m_act: "home" path: /account2/ defaults: _controller: "legacy.controller.fallback:Somefunt" pag_act: "public" m_act: "home" e.g. laravel Route::any('/account',

Creating a custom exception class and custom handler class in Laravel 5.3

徘徊边缘 提交于 2019-12-23 18:34:20
问题 Before I get to the code, let me explain my aim. My web app displays vehicles for sale. I have a need for a custom 404 page that will display 12 of the latest vehicles added to the database if the user tries to access a page that doesn't exist. I have the following... App\Exceptions\CustomException.php <?php namespace App\Exceptions; use Exception; class CustomException extends Exception { public function __construct() { parent::__construct(); } } App\Exceptions\CustomHandler.php <?php

Laravel env file is not loading

耗尽温柔 提交于 2019-12-23 15:33:39
问题 I have moved my laravel project from local to production server which is centos vps. Strange thing I'm facing is laravel can't read from .env file, And I have tested everything to make it work but no success. I have set it's permission to 777 and it's owner to the owner of vps. still no success. FYI : it is in gitignore but I have created .env file on server so this problem has nothing to do with gitignore. Can someone walk me through step by step running laravel on production server? Exactly

Check whether Laravel Controller Action is defined

*爱你&永不变心* 提交于 2019-12-23 10:38:44
问题 I have an application where I will be storing links in the database allowing the user to assign actions to the link. I want to avoid the situation where the action does not exist and I get this error; Action App\Http\Controllers\PermissionController@index2 not defined. So I would like to check whether an action exists and has route. If possible in blade but anywhere else is fine. 回答1: There isn't any built in way to do this. But we have a action helper method which generates route url based

Laravel + AngularJS Nginx routing

拟墨画扇 提交于 2019-12-23 09:23:02
问题 I have the following issue, I need to configure Nginx, so on any URL user accesses, it will keep the uri (example domain.com/some/url/ ), but pass to laravel only / and let Angular handle the routing. Route::get('/', function(){ return view('index'); }); And when accessing /api/{anything} Laravel will kick in. For now I return index.html from public folder until I find solution Here is My Config: location / { index index.html; try_files $uri $uri/ /index.html; } location /api { index index

Create comma separated list from array in laravel/blade?

落花浮王杯 提交于 2019-12-23 07:48:20
问题 I am displaying elements of an array @foreach($tags as $tag)$tag->@endforeach . The output is tag1tag2tag3 . What is the possible way to sho elements of array in tag1,tag2,tag3 . And how to not show , if there is only one element in array. 回答1: implode() is good for echoing simple data. In real project you usually want to add some HTML or logic into the loop, use $loop variable which is available since 5.3: @foreach ($arrayOrCollection as $value) {{ $loop->first ? '' : ', ' }} <span class=

Change TimeZone dynamically in laravel

荒凉一梦 提交于 2019-12-23 07:31:29
问题 In my project there is drop-down of time zones(PT,CST etc), when Admin changes the timezone from drop-down the admin panel reflects the timezone from the selected drop down. How to change Config/app.php "timezone"( Application Timezone) according to the selected option. 回答1: You can use Laravel helper function config to set timezone. However, this will affects only the request you will receive. config(['app.timezone' => $timezone]); If your goal is to change once the timezone and run on every

Image dose not move at folder path

眉间皱痕 提交于 2019-12-23 05:13:45
问题 I already given 777 permission to my images folder. Charts Table is also saving all record of image. I am going to attach table: charts structure here. public function store(Request $request) { $input = $request->all(); $tradeID= Auth::user()->trade()->create($input); if($file = $request->file('file')) { $name = time() . $file->getClientOriginalName(); $file->move('images', $name); $photo = Chart::create(['file'=>$name]); $input['photo_id'] = $photo->id; } $tradeID->chart()->create($input); }

Group by Laravel?

拜拜、爱过 提交于 2019-12-23 03:44:06
问题 I have the following query: $orders = Order::where(function ($query) use ($request) { // Filter by in process delivery if ($request->get("status") && $request->get("status") == "2") { $query->where('status', "2"); } })->groupBy('created_at')->get(); When I try to execute this query I get an error: SQLSTATE[42000]: Syntax error or access violation: 1055 'delivery.order.id' isn't in GROUP BY (SQL: select * from `order` group by `created_at`) What is problem? 回答1: In your config/database.php