mardi 5 avril 2022

laravel - can not change base URL in Docker + Laravel PHP + Nginx

I try to migrate my backend website (containing API service to mobile apps) from LAMP into docker platform. currently this docker split into 3 parts (Laravel App, database & nginx). sofar, the website launch successfully without error.

However, I need base URL to be like below:

http://backend.example.com/public/

so, if i want to login, url will be http://backend.example.com/public/login, also API url with above format like http://backend.example.com/public/api/v1

What I have tried:

  1. Set APP_URL value in .env to http://backend.example.com/public/
  2. Set below setting in config/app.php to:
'url' => env('APP_URL', 'https://backend.example.com/public'),
'asset_url' => env('ASSET_URL', null)
  1. run php artisan route:clear and php artisan migrate

but still not successfull, evertime i launch web browser, url still stuck to:

http://backend.example.com/

http://backend.example.com/login/

http://backend.example.com/api/v1/

etc

any idea to overcome above problem?

===Additional Note

  1. nginx conf for nginx docker:
server {
    listen 80;
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/public;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}
  1. original base URL in LAMP are http://backend.example.com/public/, in original i'm using LAMP (Apache+PHP+MySQL) but in current Docker I'm using (Nginx + MySQL + php:7.4-fpm), however because an error, i change something so original base url cannot be achieved anymore...

  2. Reference of This Migration can be found here.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/P3N40Va
via IFTTT

How to pass many records through Form in Laravel 8?

The essence of the problem is that I started to learn Laravel and I can not find information on how to pass many fields through the form, followed by validation. Form example:

How to do it right?

`<form class="mt-5" method="post" enctype="multipart/form-data"
    @isset($word)
        action=""
    @else
        action=""
    @endisset
@csrf
@isset($word)
    @method('PUT')
@endisset
<table class="table table-responsive-md">
    <tbody>
        <tr>
            <th>ID</th>
            <th>English</th>
            <th>Transcription</th>
            <th>Russian</th>
            <th>Ukrainian</th>
            <th>Module</th>
            <th>Action</th>
         </tr>
         @for($i = 1; $i < 3; $i++)
            <tr>
                <td></td>
                <td><input type="text" name="eng[]" class="form-control"
                                           value=""></td>
                <td><input type="text" name="transaction[]" class="form-control"
                                           value=""></td>
                <td><input type="text" name="ru[]" class="form-control"
                                           value=""></td>
                <td><input type="text" name="uk[]" class="form-control"
                                           value=""></td>
                <td><input type="text" name="category_id[]" class="form-control"
                                           value=""></td>
                <td></td>
             </tr>
           @endfor
       </tbody>
    </table>
    <a class="btn btn-secondary mt-4" href="">Back</a>
    <button class="btn btn-success  mt-4">Save</button>
</form>`

The output is like this, but I know for sure that this is not right.

^ array:6 [▼ "_token" => "Olp8kMQIFoDP9OOvV5YRihcV3FpKIHofxfYk8W7M" "eng" => array:2 [▶] "transaction" => array:2 [▶] "ru" => array:2 [▼ 1 => "www" 2 => "qqq" ] "uk" => array:2 [▶] "category_id" => array:2 [▶] ]



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/96ywYnZ
via IFTTT

lundi 4 avril 2022

Laravel blade prefix the source with tab

In the pages web browser's source I have the following tab prefix:

enter image description here

I checked out the main.blade.php which is the main layout template, but it has no any initial tabs or white spaces:

enter image description here

I don't know why this tab is rendered?! I'm using



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/MOa4ep5
via IFTTT

Error while creating PDF from DomPDF, Call to a member function stream() on string

Trying to create PDF from HTML and storing it to AWS bucket in Laravel using Barryvdh\DomPDF. It works fine, the pdf is created and is stored to aws bucket but getting error , Call to a member function stream() on string.

All this process is called through a queue job, the error response is saved to failed_jobs table in exception field in DB.

Below is the snippet code used.

$fileName = "anyfilename.pdf"
$html = \View::make('frontend.courses.certificate', [
    'course'     => "This is test course",
])->render();

$pdf = \PDF::setPaper('a4', 'landscape')->loadHtml($html);
\Storage::disk('s3')->put($s3Path, $pdf->stream($fileName)->getContent());

I have tried everything what came to my mind to solve this but nothing works. Any suggestions how to bebug this or any fix for this.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/i9It4mV
via IFTTT

i can´t save my image or my file when upload it

My problem it´s, mi folder it´s created but my file it´s not uploaded. i have this code:

if(isset($request->file_job)){
            $pathFolder = storage_path('app/contratos/'.$tarea->contratoTrey->serie->SERIE.'-'.$tarea->contratoTrey->N_CONTRATO.'/tareas/T-'.$tarea->ntarea);
            $filePath = 'app/contratos/'.$tarea->contratoTrey->serie->SERIE.'-'.$tarea->contratoTrey->N_CONTRATO.'/tareas/T-'.$tarea->ntarea;
           
            if(!\File::exists($pathFolder)) {
                \File::makeDirectory($pathFolder, 0755, true, true);
            }
            
            \Storage::disk('local')->putFileAs($filePath, $request->file_job, ($request->file_job)->getClientOriginalName());
        }

this code generate all my folder structure but not save my file (image) i don´t know that i´m doing wrong.

Thanks for help me



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/6du9pGL
via IFTTT

Change .htaccess directory in laravel 5.6

Hell folks,

In my project the .htaccess file is placed in the project root directory.

I want it placed in some other directory say '/public/setupfiles' and the project should be able to access it.

Is it possible? if yes thn how?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ReWJSKn
via IFTTT

dimanche 3 avril 2022

Laravel 5.6 ajax request internal server error

Hello i'm developing like disliked system based on https://www.itsolutionstuff.com/post/php-laravel-5-like-dislike-system-tutorialexample.html

but the ajax function throwing internal server error

this is my controller

public function ajaxRequest(Request $request)
    {
        $post = Post::find($request->id);
        $response = auth()->user()->toggleLiked($post);

        return response()->json(['success' => $response]);
    }

and this is my ajax request:

<script type="text/javascript">
    $(document).ready(function() {


        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });


        $('i.glyphicon-thumbs-up, i.glyphicon-thumbs-down').click(function(){
            var id = $(this).parents(".panel").data('id');
            var c = $('#'+this.id+'-bs3').html();
            var cObjId = this.id;
            var cObj = $(this);


            $.ajax({
               type:'POST',
               url:'/ajaxRequest',
               data:{id:id},
               success:function(data){
                  if(jQuery.isEmptyObject(data.success.attached)){
                    $('#'+cObjId+'-bs3').html(parseInt(c)-1);
                    $(cObj).removeClass("like-post");
                  }else{
                    $('#'+cObjId+'-bs3').html(parseInt(c)+1);
                    $(cObj).addClass("like-post");
                  }
               }
            });


        });


        $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
            event.preventDefault();
            $(this).ekkoLightbox();
        });
    });
</script>

this is the form for clicking the likes

    <span class="pull-right">
       <span class="like-btn">
       <i id="like" class="glyphicon glyphicon-thumbs-up "></i>
     
       <div id="like-bs3"></div>
     <span>
   </span>

what i have done is changing the routes in case it's missing something, but still throwing the same error, what should i do?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/yTxOSPG
via IFTTT