/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return array(
(new MakeSalesReceiptFromTransaction)->confirmText('dsasa')
);
}
I get undefined function confirmText()
Is there a class I'm supposed to be importing or something?
public function actions(Request $request)
{
return [
(new Actions\ActivateUser)
->confirmText('Are you sure you want to activate this user?')
->confirmButtonText('Activate')
->cancelButtonText("Don't activate"),
];
}
A resource uses the App\Nova namespace, while actions use the App\Nova\Actions namespace. You have to specify it when creating a new instance of your action.
new Actions\MakeSalesReceiptFromTransaction
Alternatively, you can keep your code as is and use the following at the top of your resource file :
use App\Nova\Actions\MakeSalesReceiptFromTransaction;
But I wouldn't recommend the second option because it can get messy if you use multiple actions in your resource.
namespace App\Nova\Actions;
use App\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use App\Services\QuickbooksService;
class MakeSalesReceiptFromTransaction extends Action
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/
public function handle(ActionFields $fields, Collection $models)
{
return Action::message("testing");
}
/**
* Get the fields available on the action.
*
* @return array
*/
public function fields()
{
return [];
}
}