Laravel! How to move from view variable to controller without redirecting the page?

I need help to transmit a view variable to the controller with the help of Laravel.

The case is as follows:
I have on display a dynamic accordion as query in the database.
Each accordion element has its specific identifier.

To view the contents of the accordion, I have a query in the database controller where I have to use as the search parameter, the id of the accordion section on which I'm going. clicked previously.

The query return quoted above interferes with the way the content is displayed by extending the accordion.

The value of the variable in view can be obtained via javascript / jquery, but I do not know how to pass this value to the controller to search the database.

If anyone can help me, I really appreciate it.

php – The laravel database creates 50 users and attaches a relationship to each user

I have to use

factory(AppUser::class, 50)->create()->each(function ($user) {

Internal runtime function in DatabaseSeeder

when i run php artisan db:seed
the exit is below

Seeding: UsersTableSeeder

   BadMethodCallException  : Call to undefined method AppUser::posts()

  at /home/ahmed/myDesgin/laravelApplication/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50
    46|      * @throws BadMethodCallException
    47|      */
    48|     protected static function throwBadMethodCallException($method)
    49|     {
  > 50|         throw new BadMethodCallException(sprintf(
    51|             'Call to undefined method %s::%s()', static::class, $method
    52|         ));
    53|     }
    54| }

  Exception trace:

  1   IlluminateDatabaseEloquentModel::throwBadMethodCallException("posts")

  2   IlluminateDatabaseEloquentModel::forwardCallTo(Object(IlluminateDatabaseEloquentBuilder), "posts", ())

  Please use the argument -v to see more details.

what is the cause of this problem and how to solve it

php – Query Transaction manually laravel pagseguro

Hi, I'm trying to manually create a transaction request by following the template sent by the author of the michaeldouglas / laravel-pagseguro component, but I'm trying to return the following error:

Non-static method laravelpagseguroFacadesPagSeguro::transaction() should not be called statically

Repository link:

Here is my request code:

 foreach($atualizar as $pagamento){
        $transaction = PagSeguro::transaction()->get($pagamento->codigo, $credentials);
        $information = $transaction->getInformation();

Anyone who can help is extremely grateful!

php – If select Laravel

I have a doubt here and would like some help.
I have a controller where I have to make a query in the box table where it checks whether the box is open or closed.

public service index (Request $ request)
$ boxes = DB :: select (& # 39; SELECT * FROM boxes INNER JOIN
users ON = JOIN boxes c ON c.data_open = c.data_open & # 39;);

    if( $caixas )
        return view('vendas.index', compact('caixas'));
        return view('vendas.caixa');

it works, but when I start with the user 1 and that I open the box, it opens and if blz, if I log out and I log in with the user 2 , he always has the box open, does not recognize that the user 2 is a closed box.

Thank you

php – How to access the storage file by using a database query in LARAVEL

I am working with the Laravel project and I am facing a problem.
I created a database model called "Product" that has a field called "product_image" and whose data type is string.

public function up()
        Schema::create('Products', function (Blueprint $table) {

Using the controller, I allowed the download of the image and the product model able to get the active name of these files with its extension, even if I am able to find this downloaded file on storage/app/example.jpg.

$file = $request->file('product_image');
        $filename = 'product_image-' . time() . '.' . $file->getClientOriginalExtension();
        $path = $file->storeAs('product-image', $filename);
        $product->product_image = $path ;

But when I run an @foreach loop on my blade model and try to extract an image over it.

@foreach ($products as $p)



I can not find anything and the image field is always displayed without the original image 🙁
enter the description of the image here

I discover the problem but do not know the solution and lost in the dark.
The current problem is in,

because this is not the base of the URL for this image.

My question is: how can we provide a URL for this particular image using the for loop that can locate this image from the storage / app / example directory?
Thank you in advance.

Printing table with jsPDF – Laravel

I'm trying to print a table that is in a Laravel view with jsPDF, but I can not complete it, the PDF is generated correctly, but the content is complex and incomplete. I have tried some answers in stackoverflow but I can not get it to work properly. I appreciate that someone can tell me what I'm doing wrong or if there is another way to get reports more convenient.

This is the pdf that is generated

Nominate in the explorer

In the header, I have the scripts corresponding to the jsPDF library

That's the table I'm trying to print

        @foreach($nominaParaImprimir as $nomina)
{{'NIT ' . $parametros(0)->nit}}
Nomina desde {{date("d/m/Y", strtotime($fechaInicial))}} hasta {{date("d/m/Y", strtotime($fechaInicial."+ 6 days"))}} Fecha de Pago {{date("d/m/Y", strtotime($fechaInicial."+ 5 days"))}}
Nombre empleado Dias
Cant H
Val H
Sub de
Salud Pension Total Recibí
{{$nomina->nombre_empleado}} {{$nomina->dias_laborados}} {{'$'.number_format($nomina->valor_dias,0)}} {{$nomina->cantidad_horas_extras}} {{'$'. number_format($nomina->valor_horas_extras,0)}} {{$nomina->cantidad_horas_festivas}} {{'$'. number_format($nomina->valor_horas_festivas,0)}} {{'$'. number_format($nomina->valor_horas_subsidio_transporte,0)}} {{'$'. number_format($nomina->salud,0)}} {{'$' . number_format($nomina->pension,0)}} {{'$' . number_format($nomina->total,0)}}
Totales {{'$' . number_format($totalNomina,0)}}

Finally, it's the javascript function that I try to correct

function imprimirTabla() {
            var pdf = new jsPDF('p', 'pt', 'letter');
            // source can be HTML-formatted string, or a reference
            // to an actual DOM element from which the text will be scraped.
            source = $('#tabla')(0);

            // we support special element handlers. Register them with jQuery-style
            // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
            // There is no support for any other type of selectors
            // (class, of compound) at this time.
            specialElementHandlers = {
                // element with id of "bypass" - jQuery style selector
                '#bypassme': function(element, renderer) {
                    // true = "handled elsewhere, bypass text extraction"
                    return true
            margins = {
                top: 80,
                bottom: 60,
                left: 40,
                width: 522
            // all coords and widths are in jsPDF instance's declared units
            // 'inches' in this case
                source, // HTML string or DOM elem ref.
                margins.left, // x coord
      , {// y coord
                    'width': margins.width, // max width of content on PDF
                    'elementHandlers': specialElementHandlers
                function(dispose) {
                    // dispose: object with X, Y of the last line add to the PDF
                    //          this allow the insertion of new lines after html
                , margins);

Laravel, Docker, PHP and Xdebug on PHPStorm

I've already found some tutorials for Apache and even Nginx, but none worked correctly for me. Could someone point to a material on this?

php – What is the right way to use the @include Blade (Laravel) directive?


server – php service command error in laravel project

I just installed laravel with all the requirements (php, composer, nodejs) and create a new broject called blog, now that I run php artisan serve
it returns an error sayingsutoload.php does not exist in the directory.
see error below …

PHP Warning:  require(/home/tibsis/.config/composer/vendor/laravel/installer/blogg/vendor/autoload.php): failed to open stream: No such file or directory in /home/tibsis/.config/composer/vendor/laravel/installer/blogg/artisan on line 18
PHP Fatal error:  require(): Failed opening required '/home/tibsis/.config/composer/vendor/laravel/installer/blogg/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/tibsis/.config/composer/vendor/laravel/installer/blogg/artisan on line 18

I tried to copy the autoload.php file from the vendor's folder and paste it into my "blogg" project folder and it still did not work.

How can I fix this problem, should I reinstall everything from scratch?

Laravel, get two functions

I would like help, In the "users"table I have the structure"referrer_id","Last name"and"activeIn this function, I can only get the names of the users in the "users"table, how can I also get the status"active"?

public function nnIndicaded() {

   return implode('
  • ', User::where('referrer_id', $this->id)->pluck('name')->all()); }