Deploy yii2 advanced on Heroku and frontend cannot find the models - heroku

I deployed a yii2 advanced and postgresql on the Heroku.
The backend works well.
When I visit frontend, it gives me an error.
Error
Class 'frontend\models\home' not found
public function getHomeSource()
{
$query = Home::find();
$home_list = $query->where('"isUsed" = 1')->orderBy('sort')->all();
return $home_list;
}
I don't know how to fix it.
Please help me!

Can you give all content of file with function getHomeSource()
Mabe you need just add use name\spase\tohomemodel\Home in top of the file

Related

API not returning updated data

I have this weird problem. It works fine on my local machine. But the problem happens when I upload this project on the live server (in a sub-domain for testing purposes). GitHub Repository
The project has one Model (other than User), "Post"
The project has one route and one API endpoint. Initially, I should get the same results from both the web route and API endpoint. The problem is when I delete a post from the web, the API result still shows that deleted post. The API returns updated results after 20-30 minutes.
Very strange issue.
If anyone knows anything about such an issue, please help me out.
I am using Livewire
App\Http\Livewire\Posts.php
public function render()
{
$posts = DB::table('posts')
->select(DB::raw("
posts.id AS id,
posts.title AS title,
posts.category AS category,
posts.author AS author
"))
->orderBy('posts.category')
->get();
$data = [
'posts' => $posts
];
return view('livewire.posts', $data);
}
api.php
Route::get('posts', function() {
$posts = DB::table('posts')
->select(DB::raw("
posts.id AS id,
posts.title AS title,
posts.category AS category,
posts.author AS author
"))
->orderBy('posts.category');
return response()->json($posts->get(), 200);
});
Actually, it was my fault. I did try
php artisan cache:clear
php artisan optimize:clear
And it did not work since there was a caching configuration in Nginx.
You know, when you are a noob at server management and end up using a nice and ready solution like myvestacp, you may end up making silly mistakes like this.
The way myvestacp is configured, it utilizes a combination of Apache and Nginx (as proxy). Without knowing the outcome, I had set the Nginx proxy as "caching" instead of "hosting-public". This is why the API result would get cached and only update after some time.
I did not face any issues so far because I did not use API before.
But thank you anyway for your time and effort.

Laravel cashier-paddle Simple Charge The checkout id issue

Cashier Paddle Version: 1.0#beta
Laravel Version: 7.0
PHP Version: 7.2.5
I am using cashier-paddle for one of my laravel 7 projects. I'm trying to apply a "one off" charge (Simple Charge) against a customer. I've followed the official documentation to integrate the package in my project but I am getting this issue "Simple Charge The checkout id must be a valid checkout id". Here are the steps that I have already completed.
Installed the official laravel cashier-paddle package using composer
require laravel/cashier-paddle
Published necessary migrations and added the necessary API Keys on my
env file
Added the #paddlejs in may master layout blade file and updated the
VerifyCsrfToken middleware so it except routes paddle/*
Added the Billable trait to the User model Configured the webhook
route and controller
// Route example
Route::post('paddle/webhook','WebhookController#handleWebhook')->name('cashier.webhook')
// WebhookController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Laravel\Paddle\Http\Controllers\WebhookController as CashierController;
class WebhookController extends CashierController
{
public function handleWebhook(Request $request)
{
logger('I can reach here!');
}
public function handlePaymentSucceeded($payload)
{
}
}
Generated the paylink variable using my controller.
// paylink variable from controller
$payLink = auth()->user()->charge(12.99, 'Test Product Title');
Finally used the variable on the paddle-button Blade component
// Blade file
<x-paddle-button :url="$payLink" class="px-8 py-4">
Buy
</x-paddle-button>
Note: The simple charge is not working but the charge for a specific product is working fine. For example this one auth()->user()->chargeProduct(619859) is working fine.
These are the steps that I have already followed to integrate the paddle simple chare on my laravel application. Hope that information may help you. Let me know if I am doing anything wrong or missed any steps. I will be really very thankful if anyone can help me to solve the issue. Thanks in advance.
Thanks for visiting the question. After doing some research I've fixed the issue. Everything was fine. Just need to specify the webhook URL in the charge method. I think it was not mentioned in laravel documentation. I'm posting the answer so anyone can get a solution in the future.
// paylink variable from controller
$payLink = auth()->user()->charge($total, 'Product Title', [
'webhook_url' => 'webhook URL here',
]);

How to avoid this bug in Scrutinizer for Laravel project?

When I check my Laravel app on Scrutinizer shows me some bugs like this one:
The method with does only exist in Illuminate\View\View, but not in Illuminate\Contracts\View\Factory.
The code is:
$data['records'] = Record::all()->count();
$data['users'] = User::all()->count();
return view('dashboard.index')
->with('data', $data);
It works perfect, but on every analisys it shows me the same error. I think is a problem with my View class instantation but I don't know how to solve it.
Is there any good guide to configure Scrutinizer for Laravel projects?
Thanks in advance.

Magento Custom Controller working on local, throwing 500 error on staging server

I am having quite a strange problem. I have just pushed my local build to our staging server. I have a custom module with custom controllers which, when accessed locally, work perfectly fine. However, when I attempt to access ONE SPECIFIC controller on staging, it throws a 500 server error. All of the other controllers I wrote work except for this custom IndexController.php I wrote. Again, everything works 100% on my local build. I have triple checked all of my .htaccess files, but maybe I’m missing something.
The strangest part of all of this is that it was working on staging two days ago! I have no idea what is causing this.
Does anyone have any suggestions on how I might go about troubleshooting this? Or, by chance, a solution?
1: Clear your cache AND sessions .
2: Check if your module is installed using the free/open-source Module List Module
3 Drop some debugging code in the following method. The var_dumps will tell you which files/classes Magento's routers are looking for with your module, but can't find.
File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
protected function _validateControllerClassName($realModule, $controller)
{
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
var_dump($controllerFileName);
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
var_dump($controllerFileName);
return false;
}
// include controller file if needed
if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
var_dump($controllerFileName);
return false;
}
return $controllerClassName;
}

Magento - order details are not displayed in the admin panel

We have an ecommerce magento store. Right now, we are experiencing a weird problem, which i am unable to understand and debug.
For some of the orders, no details are displayed in the order details page of magento admin, though the mail is correctly sent to the client and cc'd to our email id.
Screenshot for admin order details page :-
Screenshot for email containing order details :-
Why is this happening ?? I tried to check the pattern but was unable to. Please help me on this issue as i am not a pro in magento and any help from your side will do the work for me.
Try also this, it worked for me (from https://magentary.com/kb/php-syntax-error-after-supee-7405-unexpected/):
Problem description
After SUPEE-7405 patch Sales Order Management screen in Magento Backend is blank or the following error is reported in PHP error log:
PHP Parse error: syntax error, unexpected '[' in app/code/core/Mage/Adminhtml/Helper/Sales.php on line 124
Cause
SUPEE-7405 is prepared with PHP 5.4 in mind, older PHP versions are incompatible with new language constructions used.
Solution
Change line 124 in app/code/core/Mage/Adminhtml/Helper/Sales.php from $links = []; to $links = array();:
--- app/code/core/Mage/Adminhtml/Helper/Sales.php
+++ app/code/core/Mage/Adminhtml/Helper/Sales.php
## -121,7 +121,7 ##
public function escapeHtmlWithLinks($data, $allowedTags = null)
{
if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
- $links = [];
+ $links = array();
$i = 1;
$data = str_replace('%', '%%', $data);
More than likely you have a local or community module causing some kinds of fault, if the page is not rendering all the way for some orders, I would presume these are orders that are using this local and/or community module.
A few things you can try are:
1) disable all local modules via local.xml
2) disable community modules via app/etc/Company_Modulename.xml and set active to false
after disabling each retry viewing the orders until you find the culprit.
Also, viewing the page source may help lead to where the output is stopping and there also may be errors at the very end of the page source.
hope this helps.
I solved this problem when I replace the tax.phtml file in
app/design/adminhtml/default/default/template/sales/order/totals
with my original file. Try it.
I disabled all plugins. It seemed that the apptha one step checkout plugin was responsible for this in my case.
I believe that this issue is due to default Magento, as the files does not point to any third party checkout extensions.
If the SUPEE-7405 patch has caused this, please check that your system does not run on PHP 5.3.
The patch breaks PHP 5.3 compatibility, by introducing usage of array literals in app/code/core/Mage/Adminhtml/Helper/Sales.php (line 124), which became available in PHP since version 5.4, so the minimum PHP version required, after applying it, is PHP 5.4:
// patched app/code/core/Mage/Adminhtml/Helper/Sales.php lines 121-124
public function escapeHtmlWithLinks($data, $allowedTags = null)
{
if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
$links = [];
To fix this, and restore PHP 5.3 compatibility (allowing orders to show up again in admin screens), simply correct this with old PHP5.3 equivalent:
// patched and fixed app/code/core/Mage/Adminhtml/Helper/Sales.php lines 121-124
public function escapeHtmlWithLinks($data, $allowedTags = null)
{
if (!empty($data) && is_array($allowedTags) && in_array('a', $allowedTags)) {
$links = array();
Change PHP 5.3 to 5.6 on your Server , logout and in . Resfresh you Cache.
It will be run.
For the Version 1.9.2.3 magento.

Resources