mardi 21 juillet 2020

Socialite laravel library facebook login issue

enter image description hereI have two sites one is the main site, the other is the dev of main site, and the same code as the main site. I configure socialite laravel library on both sites for Facebook login dev site working fine but the main site generates permission issues also view in screenshot both Facebook APP ID's are live and callback URL is also correct but showing error.



via Chebli Mohamed

laravel 5.8 scheduler not working automatically have to trigger manual

i am running command php artisan schedule:run and it will work . but i want to update thing everyMinute(); automatically without trigger command every time .if i have to trigger it mannualy then what is the meaning of scheduler

  1. my command file
  public function handle()
    {
        $update = Roi::find(12);
        $update->level = 48;
        $update->save();
    } 

2.kernal.php

 protected function schedule(Schedule $schedule)
    {
        $schedule->command('level:update')->everyTwoMinutes();
    }

i am checking updates in updated_at timestamp in database



via Chebli Mohamed

Laravel 7 deploy in shared hosting (hostgator) Error

I am trying to deploy my Laravel app in a shared hosting (hostgator).

  • I have upgraded php version to 7.3 and it shows when tested with phpinfo().
  • Also I have created an index.html file on the root to test whether the .htaccess working or not and it worked.
  • I have removed the files under cache folder inside bootstrap folder.
  • I checked my .env file whether it has any mis-configuration or not.
  • I have given 777 permission to bootstrap and storage folder

my .htaccess is:

<IfModule mod_rewrite.c>

    Header set Access-Control-Allow-Origin "*"
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
    
    RewriteEngine On

    # Handle Authorization Header
    
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors On
   php_flag display_startup_errors On
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 260M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors On
   php_flag display_startup_errors On
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 260M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php72"
   php_value upload_max_filesize 256M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

In my error.log file I am having:

[21-Jul-2020 11:29:33 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'ixed.7.1.lin' (tried: /opt/php71/lib/php/extensions/no-debug-non-zts-20160303/ixed.7.1.lin (/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/ixed.7.1.lin: undefined symbol: _zval_ptr_dtor), /opt/php71/lib/php/extensions/no-debug-non-zts-20160303/ixed.7.1.lin.so (/opt/php71/lib/php/extensions/no-debug-non-zts-20160303/ixed.7.1.lin.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[21-Jul-2020 06:29:33 America/Chicago] PHP Fatal error:  Uncaught ReflectionException: Class config does not exist in /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
Stack trace:
#0 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): ReflectionClass->__construct('config')
#1 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(687): Illuminate\Container\Container->build('config')
#2 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('config', Array, true)
#3 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(633): Illuminate\Foundation\Application->resolve('config', Array)
#4 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Container\Container->make('config', Array)
#5 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/C in /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 807

and I am getting the following error when load site in browser:

Fatal error: Uncaught ReflectionException: Class config does not exist in /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php:805 Stack trace: #0 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): ReflectionClass->__construct('config') #1 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(687): Illuminate\Container\Container->build('config') #2 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\Container\Container->resolve('config', Array, true) #3 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php(633): Illuminate\Foundation\Application->resolve('config', Array) #4 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\Container\Container->make('config', Array) #5 /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/C in /home2/courage/www.mysite.xyz/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 807



via Chebli Mohamed

Laravel: How to repeat a function until something happens?

I am building a web service for an android application. When some thing happens in server, I broadcast a message to a device via Laravel-Echo and Socket.io. Sometimes, something may prevent the device from listening to the message for a while (for example interrupting internet connection), So in such cases, I have to broadcast again. In fact, If the device doesn't get the message I will have to broadcast again for several times (say 10). To handle this, If the device get the message it will post to a function and in that function, I store a variable in the Redis which represents that the device listened successfully.

The problem is, I don't know how to implement this cycle of Redis check. After the first broadcast, I need to check the Redis every 30 seconds for 7 times to see if the variable exists. I don't know to implement this by events, queue or tasks.

Thanks in advance.



via Chebli Mohamed

Laravel -request fails mySQL update

The question is this: There is a table with forms in each row. Created with dataTables:

{
    "data": null,
    "targets": -1,
    "defaultContent": "<form action='start-data-submit'> <input  name=\"prod_barcode\" />"
},
{
    "data": null,
    "targets": -1,
    "defaultContent": " <input name=\"prod_quantity\"/>"
},
{
    "data": null,
    "targets": -1,
    "defaultContent": " <input name=\"prod_price\" />"
},
{
    "data": "id",
    "visible": false,
    "searchable": false
},
{
    "data": "updated_at",
    "visible": false,
    "searchable": false
},
{
    "data": null,
    "defaultContent": " <button name=\"submit\" >Update</button> </form>"
}

on click in the form, the following is processed:


$('#start-data tbody').on('click', 'button', function () { //click update
            var row = $(this).closest('tr');
            var data = table.row(row).data().id;
            var info = table.row(row).$("input[name='prod_barcode']").val();
            var infoq = table.row(row).$("input[name='prod_quantity']").val();
            var infop = table.row(row).$("input[name='prod_price']").val();
            var url = "start-data-submit/" + "id=" + data + "&prod_barcode=" + info + "&prod_quantity=" + infoq + "&prod_price=" + infop + " ";
            $(location).attr('href', url);

route:

Route::get('start-data-submit/{id}&{prod_barcode}&{prod_quantity}&{prod_price}','StartDataController@update')

controller:

 public function prodview(Request $request)
    {
        $timestamps = Carbon::today();
        $prod_barcode = $request->route('prod_barcode');
        $prod_quantity = $request->route('prod_quantity');
        $prod_price = $request->route('prod_price');
        $uid = $request->route('id');

        DB::table('products')
            ->where('id', $uid)
            ->update(
                [
                    'updated_at' => $timestamps,
                    'prod_barcode' => $prod_barcode,
                    'prod_quantity' => $prod_quantity,
                    'prod_price' => $prod_price
                ]
            );
    }

It seems that everything is visible - the variables have the necessary values, but update does not happen, it does not give an error.

var_dump($timestamps,$prod_barcode,$prod_quantity,$prod_price,$uid);

issues:


object(Carbon\Carbon)#344 (3) { ["date"]=> string(26) "2020-07-17 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(14) "prod_barcode=2" string(15) "prod_quantity=4" string(13) "prod_price=78" string(7) "id=4680"

where else to dig?



via Chebli Mohamed

How to add the trim function to validation rules in Laravel Request?

I have a validation rule as shown below. I am using exists to ensure that the contract is unique. The issue now is that contract numbers are stored with spaces in the database so this validation is not working for those cases (for example it will say the contract number does not exist which is due to the space before the number). To solve this, I want to do trim(contract_number). Please how can I apply the trim function to the contract_number below?

public function rules()
{
    return [   
        'tel' => 'required|max:25',
        'contract' => 'required|digits:9|exists:accounts,contract_number',
        'nom' => 'required|max:255',
        'language' => 'required|max:2',
        'g-recaptcha-response' => 'required|captcha',
    ];
}


via Chebli Mohamed

Making an OAuth request with Laravel for Stripe

I was translating following PHP code:

$person = \Stripe\Account::createPerson(
    '', // id of the account created earlier
    [
       'person_token' => $token,
    ]);

To:

$making_user = $stripe->account()->persons()->create(
    $request[0], // id of the account created earlier
    [
       'person_token' => $request[1],
    ]);

Above Laravel code works find without any issue. Does anyone have any idea that what can be the equivalent Laravel syntax of the following:

$response = \Stripe\OAuth::token([
    'grant_type' => 'authorization_code',
    'code' => 'ac_123456789',
]);

I'm using following as equivalent, but it is giving me error of invalid method "oauth"

$making_account = $stripe->oauth()->create([
        'grant_type' => $request['code'],
        'code' => 'ac_123456789',
    ]);

I'm not finding anywhere its syntax anyone have an idea what will be the Laravel syntax of making Oauth call?



via Chebli Mohamed