Call to undefined function App\Http\Controllers\exec() [closed] - laravel

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
Please help me. The website works fine in the local host, but it is having error in the C panel. How to solve?
the path is:
app/config/app.php

you can use Process Component of Symfony that is already in Laravel
http://symfony.com/doc/current/components/process.html
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
inside your elcdetails use
$macAddr = new Process('getmac');
$macAddr->run();
// executes after the command finishes
if (!$macAddr->isSuccessful()) {
throw new ProcessFailedException($macAddr;
}
//or whatever you want to do with the output.
echo $macAddr->getOutput();
note that, if you are trying to get the client mac address, short answer is you cannot.

From your image, I'm supposing you defined the public function exec() function somewhere above or below in your controller. You cannot reference to it that way since its a method in your controller class.
So change it to this instead. $macAddr = $this->exec('getmac');

Related

PUT and DELETE route is not showing in laravel route list on apiResource [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
I added apiResource routes in my api.php file. Although it shows all the resourceful routes for product/category, it is not showing the routes for PUT and DELETE methods in the case of products routes.
Showing 404 not found error.
Any help?
You can solve the missing parameter names using the parameters method.
Route::prefix('products')->group(function() {
Route::apiResource('/', \App\Http\Controllers\ProductController::class)
->parameters(['' => 'product']);
Route::apiResource('/categories', \App\Http\Controllers\CategoryController::class);
});
That should give you the following:
Note that it is a convention to make your resources plural rather than singular.
You can accomplish a lot using scoped nested resources and shallow nesting:
Route::apiResource('products', ProductController::class);
Route::apiResource('products.categories', ProductCategoryController::class);
Route::apiResource('products', ProductController::class);
Route::apiResource('products.categories', ProductCategoryController::class)->shallow();

Summation method laravel [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have two fields, views, which just counts views, and add_to_views, a number that we add to views.
I need to display the sum of these numbers in the blade. Of course, you can just do this and everything will work.
{{ $article->views + $article->add_to_views }} Views
But I want to make the summation function separately and output the already ready number
Here is what I am trying to do, in the Article model itself I create a method
public function getTotalViews() {
return $this->views + $this->add_to_views;
}
Further in the controller I call it
$article = Article::where('id')->first();
$article->getTotalViews();
And I bring to the blade
{{ $article->getTotalViews() }} Views
But I get the error
Call to a member function getTotalViews() on null
You're missing the ID for the Article that you're trying to get so it is null.
It should actually be something like:
$article = Article::where('id', 1)->first();
Or alternatively, you could do
$article = Article::find(1);
For a longer explanation on the find method:
https://laravel.com/docs/8.x/eloquent#retrieving-single-models

Running a Cron job at some time in future, but only one time (Laravel) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have to send a email using cron job in laravel, the flow is that the user will select the time for the email to be sent. ones done, that email would be sent at that time but only ones, we dont have to send it again and again.
You can dispatch the job with the delay method.
For exampe this job will be run in one day from now:
dispatch(YourJob::class)->delay(now()->addDay());
Doc ref about delayed job https://laravel.com/docs/8.x/queues#delayed-dispatching
I suggest using Laravels queues, more specifically the Mailer::later and the Mailer::laterOn method for that regard. You can delay the sending of the mail and it's only getting executed once.
YourMailable::later(now()->addMinutes(10))
or without a mailable:
Mail::later(now()->addMinutes(10), 'emails.view', $data, function ($message) {
//
});
You can also specify a specifc queue within your Mailable:
use Illuminate\Mail\Mailable;
class YourMailable extends Mailable
{
protected string $queue = 'mails-queue';
// ...
}
With the Mail facade you can use the laterOn method:
Mail::laterOn('mails-queue', now()->addMinutes(10), 'emails.view', $data, function ($message) {
//
});

How to use getoproperty in UFT [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
In my application when I click on save a reference no will be generated.it will keep on changing on every time application runs.I want to get this reference no in qtp report
Reference no is shown on a webelement.I stored the webelement in object repository with name 'reference'
My code is
Dim refernceno,test
test="001"
refernceno=browser("abc").page("abc"). Webelement ("reference"). Getroproperty ("reference")
Reporter.ReportEvent micpass,"Test passed"&test,"Reference"&refernceno
But the result shown is only Test passed 001
No reference no is showing
Kindly suggest how to use getroproperty
GetROProperty is used to fetch the set of properties defined by UFT from the object in the application. You can see these properties by using the object spy.
UFT allows you to access the Web DOM attributes by using the attribute/ syntax in GetROProperty (and other places).
Try:
refernceno = Browser("abc").Page("abc").Webelement("Reference").GetROProperty("attribute/reference")

ASP.NET BOILERPLATE: javascript to call application service [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
ASP.NET BOILERPLATE: I have a table Asset for which I have created AssetApplicationService with base class CRUDAsync; I have wired up AssetController, & appropriate DTO's, I am able to retrieve data and show on the list as similar to user list.
when I click on Create New Asset,I am able to bring the modal dailog as well until now it is all good, I have copied the user\index.js and tailored to call my asset application service from javascript...this is where i am struck
var _assetService = abp.services.app.asset; //line1
var _$modal = $('#AssetCreateModal');
var _$form = _$modal.find('form');
line 1 returns me undefined when I debug through alert(_assetService), not sure why...where as abp.services.app.user, role works fine.
AssetApplicationService must be implemented by IApplicationService.
public interface IAssetApplicationService : IApplicationService
{
}
public class AssetApplicationService : IAssetApplicationService
{
}
Note: I've replied your previous question. Please mark the answer as solution if that worked for you.

Resources