lundi 29 novembre 2021

Is it possible to copy file directly from sign url fetch from amazon S3?

I have fetch url from AWS Bucket like this: https://{bucket_path}/iportalDocuments/99/aid.jpeg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIARYDJGMIUARGRF2Y3%2F20211130%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20211130T065101Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1200&X-Amz-Signature=f2e7ccba4e7d42238d03c311cc0fb9768fb47b52891d8cbe86def3f4f827762e

Is it possible to copy file from url using spatie library. Thank you in advance..



via Chebli Mohamed

Calling the failed function: 'should not be called statically' in laravel 5.4

I use version laravel 5.4

In Helpers/Helper.php

public function test()
{
  return 'success';
}

In controller

use App\Helpers\Helper;

public function index()
{
  $val = Helper::test();
  dd($val);
}

Error : Helper::test() should not be called statically

I called the function inside helper to use it. But got the error as above. Please show me how to get the function in helper. Thank you



via Chebli Mohamed

Laravel complex relationship many to many

I’m building a app in laravel and now I’m doing a payments resource.

The ideia is select many orders in the list to receive in same time. And in this receives can be used many type of payment (money, credit).

Now I has this tables order(id, total), paymentTypes(id, paymentName), payments(id, payment_type_id, value) and order_payments(order_id, payment_id).

This structure is more adequate to this situation? And how can I get orders with all payments and the other orders payed together?

Any help is important.

Thanks everyone .



via Chebli Mohamed

Laravel 5.8 stopped sending email

Sending emails from my system has stopped working at all. .env settings are ok. I tried to run this code to test:

php artisan tinker

Mail::getSwiftMailer()->registerPlugin (
    new Swift_Plugins_LoggerPlugin(new Swift_Plugins_Loggers_EchoLogger(false))
);
$to = 'youraddress@example.com';
Mail::raw('Testmail', function ($message) use($to) {  
    $message->to($to)->subject('Testmail'); 
});

and I'm getting this error:

PHP Warning:  stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/usuario/dev/dev-contaja/vendor/predis/predis/src/Connection/StreamConnection.php on line 127
PHP Warning:  stream_socket_client(): unable to connect to tcp://redis:6379 (php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution) in /home/usuario/dev/dev-contaja/vendor/predis/predis/src/Connection/StreamConnection.php on line 127
Predis/Connection/ConnectionException with message 'php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution [tcp://redis:6379]'

I'm using use docker.



via Chebli Mohamed

AJAX json response data undefined in Laravel 5.7

I have to get response data from API I have succeeded in response but when I am getting one response of data then I have got an undefined error. I am trying to get an error message from API on button click event or display the alert message of API error response of data.

Controller :

 public function apiStatus(Request $request)
{

    $to =  $this->shop->api_test_phone;

    $curl = curl_init();
    $response = my_api;

    curl_setopt($curl, CURLOPT_URL, $response);
    curl_exec($curl);

    $response = json_encode($response);
    curl_close($curl);
    return $response;
}

Blade file:

<script type="text/javascript">
$(document).on('click','#checkApi',function(){
    startAjaxLoading();
    $.ajax({
            type: "GET",
            cache: false,
            url: "",
            success: function (response) 
            {
                console.log(response);
            
                if (response == true) 
                { 
                    var msg = response.message;
                    console.log(msg);
                    notie.alert({text: msg });
                    stopAjaxLoading();
                }
                else
                {
                    var msg = response.message;
                    console.log(msg);
                    notie.alert({ text: msg });
                    stopAjaxLoading();
                }
            }     
        });
    });


via Chebli Mohamed

dimanche 28 novembre 2021

Adding validation if another validation passed in laravel FormRequest

Is it possible to add validation if another validation passed for example I have the following validation rules

return [
            'name' => ['required', 'string', 'min:3', 'max:30'],
            'password' => ['required', 'min:6'],
            'photo' => ['imageable'],
            'business_uuid' => ['required', 'uuid', 'exists:businesses,uuid'],
        ];

and I would like if the business_uuid validation passed to add validation for the phone number

'phone' => ['nullable', 'phone:'.$countryCode],

notice that I'm the country code will be brought from the business That's why I'm I'd like to add it if the validation passed



via Chebli Mohamed

vendredi 26 novembre 2021

real-time data finder - search with multiple models

i need to make my search engine work with multiple data tables

right now get data from the model "Registro".

    public function buscador(){
        
        return view('posts.index');
        
    }
        public function search(Request $request){
            
            $results = Registro::where('cliente', 'LIKE', "%{$request->search}%")->get();
            
            return view('posts.results', compact('results'))->with(['search' => $request->search])->render();
            
        }
        public function show(Request $request){
            
            $post = Registro::findOrFail($request->id);
            return view('posts.post', compact('post'))->render();
            
       
    
}

can search with multiple models?



via Chebli Mohamed