lundi 30 octobre 2023

Get query results even with null foreign key

I have a query in which I have multiple relationships.

The foreign key 'acquirente_corretor_id' can be null or not. If it is different from null, it has a relationship with the dobby table.

I have the following query, but it only works for 'acquirente_corretor_id' that is not null. Only displays the result with this key other than null.

I want it to show the result of 'acquirente_corretor_id' even though it is null, merging.

One more thing, you only query the acquirer relationship if the variables $empresa_recebedora, $acquirente, $serial are different from null.

How to make? I've tried different forms of querying and it doesn't show.

$contratos = Contrato::with([
                    'parcela',
                    'cliente',
                    'status',
                    'operador',
                    'tabela',
                    'adquirente',
                    'bancos',
                    'bancos.empresa',
                    'bancos.banco',
                    'adquirente'
                ])
                    ->whereHas('cvs', function ($q) use ($cv) {
                        if (!is_null($cv)) {
                            $q->where('cv', $cv);
                        }
                    })
                    ->whereHas('bancos', function ($q) use ($banco, $empresa_pagadora) {
                        if (!is_null($banco)) {
                            $q->where('banco_id', $banco);
                        }
                        if (!is_null($empresa_pagadora)) {
                            $q->where('empresa_id', $empresa_pagadora);
                        }
                    })
                    ->whereHas('cliente', function ($q) use ($cliente) {
                        if (!is_null($cliente)) {
                            $q->where('nome', 'LIKE', "%{$cliente}%");
                        }
                    })
                    ->whereHas('adquirente.maquineta.empresa', function ($q) use ($empresa_recebedora) {
                        if (!is_null($empresa_recebedora)) {
                            $q->where('empresa_id', $empresa_recebedora);
                        }
                    })
                    ->whereHas('adquirente.maquineta.adquirente', function ($q) use ($adquirente) {
                        if (!is_null($adquirente)) {
                            $q->where('adquirente_id', $adquirente);
                        }
                    })
                    ->whereHas('adquirente.maquineta', function ($q) use ($serial) {
                        if (!is_null($serial)) {
                            $q->where('numero_serie', $serial);
                        }
                    })
                    ->when($status, function ($query, $status) {
                        $query->whereIn('contratos.status_id', $status);
                    })
                    ->when($ca, function ($query, $ca) {
                        $query->where('contratos.conciliacao_adquirente', $ca);
                    })
                    ->when($cb, function ($query, $cb) {
                        $query->where('contratos.conciliacao_bancaria', $cb);
                    })
                    ->when($operador, function ($query, $operador) {
                        $query->where('contratos.operador_id', $operador);
                    })
                    ->when($multiplicador, function ($query, $multiplicador) {
                        $query->where('contratos.multiplicador_id', $multiplicador);
                    })
                    ->when($gerente, function ($query, $gerente) {
                        $query->where('contratos.gerente_id', $gerente);
                    })
                    ->when($indicador, function ($query, $indicador) {
                        $query->where('contratos.indicador_id', $indicador);
                    })
                    ->when($valor_liquido, function ($query, $valor_liquido) {
                        $query->where('contratos.valor_liquido', 'LIKE', "{$valor_liquido}%");
                    })
                    ->where(function ($query) use ($inicio, $fim) {
                        if (!is_null($inicio) && !is_null($fim)) {
                            $query->whereBetween('data_operacao', [$inicio, $fim]);
                        }
                    })                    
                    ->orderBy($request->sortField, $sortOrder)
                    ->get()
                    ->each(function ($query) {
                        $pagadoras = $query->bancos;
                        foreach ($pagadoras as $pagadora) {
                            $empresas[] = $pagadora->empresa['nome'];
                            $bancos[] = $pagadora->banco['nome'];
                            $recebedores[] = $pagadora->cpf . ' - ' . $pagadora->nome;
                        }
        
                        $cvs = $query->cvs;
                        foreach ($cvs as $codigo) {
                            $codigos[] = $codigo->cv;
                        }
        
                        $query->empresas_pagadoras = implode(', ', $empresas);
                        $query->bancos_pagadores = implode(', ', $bancos);
                        $query->lista_codigos = implode(', ', $codigos);
                        $query->recebedores = implode(', ', $recebedores);
                    });

I tried solving it this way, but I get the following error:

Call to undefined method Illuminate\Database\Query\Builder::acquirente()

One more thing, you only query the acquirer relationship if the variables $empresa_recebedora, $acquirente, $serial are different from null

`$contratos = Contrato::with([ 'parcela', 'cliente', 'status', 'operador', 'tabela', 'bancos', 'bancos.empresa', 'bancos.banco', 'adquirente' ]) ->whereHas('cvs', function ($q) use ($cv) { if (!is_null($cv)) { $q->where('cv', $cv); } }) ->whereHas('bancos', function ($q) use ($banco, $empresa_pagadora) { if (!is_null($banco)) { $q->where('banco_id', $banco); } if (!is_null($empresa_pagadora)) { $q->where('empresa_id', $empresa_pagadora); } }) ->whereHas('cliente', function ($q) use ($cliente) { if (!is_null($cliente)) { $q->where('nome', 'LIKE', "%{$cliente}%"); } }) ->whereHas('adquirente', function ($q) use ($empresa_recebedora, $adquirente, $serial) { $q->whereHas('adquirente.maquineta.empresa', function ($q) use ($empresa_recebedora) { if (!is_null($empresa_recebedora)) { $q->where('empresa_id', $empresa_recebedora); } }) ->whereHas('adquirente.maquineta.adquirente', function ($q) use ($adquirente) { if (!is_null($adquirente)) { $q->where('adquirente_id', $adquirente); } }) ->whereHas('adquirente.maquineta', function ($q) use ($serial) { if (!is_null($serial)) { $q->where('numero_serie', $serial); } }); }) ->when($status, function ($query, $status) { $query->whereIn('contratos.status_id', $status); }) ->when($ca, function ($query, $ca) { $query->where('contratos.conciliacao_adquirente', $ca); }) ->when($cb, function ($query, $cb) { $query->where('contratos.conciliacao_bancaria', $cb); }) ->when($operador, function ($query, $operador) { $query->where('contratos.operador_id', $operador); }) ->when($multiplicador, function ($query, $multiplicador) { $query->where('contratos.multiplicador_id', $multiplicador); }) ->when($gerente, function ($query, $gerente) { $query->where('contratos.gerente_id', $gerente); }) ->when($indicador, function ($query, $indicador) { $query->where('contratos.indicador_id', $indicador); }) ->when($valor_liquido, function ($query, $valor_liquido) { $query->where('contratos.valor_liquido', 'LIKE', "{$valor_liquido}%"); }) ->where(function ($query) use ($inicio, $fim) { if (!is_null($inicio) && !is_null($fim)) { $query->whereBetween('data_operacao', [$inicio, $fim]); } }) ->orderBy($request->sortField, $sortOrder) ->get() ->each(function ($query) { $pagadoras = $query->bancos; foreach ($pagadoras as $pagadora) { $empresas[] = $pagadora->empresa['nome']; $bancos[] = $pagadora->banco['nome']; $recebedores[] = $pagadora->cpf . ' - ' . $pagadora->nome; }

            $cvs = $query->cvs;
            foreach ($cvs as $codigo) {
                $codigos[] = $codigo->cv;
            }

            $query->empresas_pagadoras = implode(', ', $empresas);
            $query->bancos_pagadores = implode(', ', $bancos);
            $query->lista_codigos = implode(', ', $codigos);
            $query->recebedores = implode(', ', $recebedores);
        });`


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

dimanche 29 octobre 2023

Unable to display data from database on a card using laravel

Even though there are many solutions provided for this error, I am encoutering, I have not find the solution yet, below is the error I am getting when trying to display data from the database on the bootstrap card ") ErrorException Undefined variable: published_articles (View: /home/nosi/Oresol-Lesotho-Skills-Exercise/blog/resources/views/article_data.blade.php) (View: /home/nosi/Oresol-Lesotho-Skills-Exercise/blog/resources/views/article_data.blade.php"

below is my route inside the web.php:

  Route::get('article_data', 'PublishArticlesController@retrieveArticles')->name('article_data');

below is my controller:

public function retrieveArticles(){

$articles = PublishArticle::latest()->paginate(6);
return view('article_data')->with(['published_articles'=>$articles]);

}

below is my blade file which is inside views, articles_data.blade.php:

    @extends('layouts.public_navbar')

@section('content')
<div class="container text-center">
    <h1>Explore Published Articles</h1>
</div>
<div class="container">
    <div class="card-deck row">
    @foreach ($published_articles as $article)
            <div class="col-xs-12 col-sm-6 col-md-4">
                <div class="card">
                    <div class="view overlay">
                        <a href="#!">
                            <div class="mask rgba-white-slight"></div>
                        </a>
                    </div>
                    <div class="card-body">
                        <h4 class="card-title"></h4>
                        <p>Author: </p>
                        <p class="card-text"></p>
                        <a href="" class="btn btn-primary btn-md">Read more</a>
                    </div>
                </div>
            </div>
        @endforeach
    </div>
</div>

<!-- Add Bootstrap JS and Popper.js scripts (required for Bootstrap) -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
@endsection

your help will be highly apreciated



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

samedi 28 octobre 2023

Laravel getting data from the database in .js file

I need to change the series values ​​in the .js file by pulling data from the database, how can I do this? @php not working in js file

_wChartTwo.28581ae9.js file:

window.addEventListener("load",function(){try{let s=sessionStorage.getItem("theme");if(JSON.parse(s).settings.layout.darkMode){var o="dark";Apex.tooltip={theme:o};var a={chart:{type:"donut",width:370,height:430},colors:["#622bd7","#e2a03f","#e7515a","#e2a03f"],dataLabels:{enabled:!1},legend:{position:"bottom",horizontalAlign:"center",fontSize:"14px",markers:{width:10,height:10,offsetX:-5,offsetY:0},itemMargin:{horizontal:10,vertical:30}},plotOptions:{pie:{donut:{size:"75%",background:"transparent",labels:{show:!0,name:{show:!0,fontSize:"29px",fontFamily:"Nunito, sans-serif",color:void 0,offsetY:-10},value:{show:!0,fontSize:"26px",fontFamily:"Nunito, sans-serif",color:"#1ad271",offsetY:16,formatter:function(t){return t}},total:{show:!0,showAlways:!0,label:"Total",color:"#888ea8",formatter:function(t){return t.globals.seriesTotals.reduce(function(n,e){return n+e},0)}}}}}},stroke:{show:!0,width:15,colors:"#0e1726"},series:[985,737,270],labels:["Apparel","Sports","Others"],responsive:[{breakpoint:1440,options:{chart:{width:325}}},{breakpoint:1199,options:{chart:{width:380}}},{breakpoint:575,options:{chart:{width:320}}}]}}else{var o="dark";Apex.tooltip={theme:o};var a={chart:{type:"donut",width:370,height:430},colors:["#622bd7","#e2a03f","#e7515a","#e2a03f"],dataLabels:{enabled:!1},legend:{position:"bottom",horizontalAlign:"center",fontSize:"14px",markers:{width:10,height:10,offsetX:-5,offsetY:0},itemMargin:{horizontal:10,vertical:30}},plotOptions:{pie:{donut:{size:"75%",background:"transparent",labels:{show:!0,name:{show:!0,fontSize:"29px",fontFamily:"Nunito, sans-serif",color:void 0,offsetY:-10},value:{show:!0,fontSize:"26px",fontFamily:"Nunito, sans-serif",color:"#0e1726",offsetY:16,formatter:function(e){return e}},total:{show:!0,showAlways:!0,label:"Total",color:"#888ea8",formatter:function(e){return e.globals.seriesTotals.reduce(function(i,l){return i+l},0)}}}}}},stroke:{show:!0,width:15,colors:"#fff"},series:[985,737,270],labels:["Apparel","Sports","Others"],responsive:[{breakpoint:1440,options:{chart:{width:325}}},{breakpoint:1199,options:{chart:{width:380}}},{breakpoint:575,options:{chart:{width:320}}}]}}var r=new ApexCharts(document.querySelector("#chart-2"),a);r.render(),document.querySelector(".theme-toggle").addEventListener("click",function(){let t=sessionStorage.getItem("theme");JSON.parse(t).settings.layout.darkMode?r.updateOptions({stroke:{colors:"#0e1726"},plotOptions:{pie:{donut:{labels:{value:{color:"#bfc9d4"}}}}}}):r.updateOptions({stroke:{colors:"#fff"},plotOptions:{pie:{donut:{labels:{value:{color:"#0e1726"}}}}}})})}catch(s){console.log(s)}});

analytics.blade file:

 <div class="col-xl-4 col-lg-12 col-md-12 col-sm-12 col-12 layout-spacing">
            <x-widgets._w-chart-two title="Sales by Category"/>
        </div>


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

vendredi 27 octobre 2023

What is the optimised way to pull all items related to parent table from the mysql table?

Suppose we have a table of order consisting of order ids, what would be considered 'best practice' in terms of fetching all item data with their order?

Order table:
--------

| id | name | email |  phone | event_id |
|---- |------| -----|-----| -----|
| 1    | Anish  | anish@gmail.com | 8233472332| 1765 |
| 2    | ABC    | abc@gmail.com   | 784472332| 1765 |
| 3    | XYZ    | xyz@gmail.com   | 646322332| 1525 |

items table:
------------


| id | order_id | category |  qty | price |
|---- |------| -----|-----| -----|
| 1    | 1  | person 1 | 2| 299 |
| 2    | 1    | person 2   | 1| 399 |
| 3    | 2    | person 1   | 1| 299 |

I want to fetch all items and their order name, email, phone in a single query.

Expected result

| name | email | category |  qty | price |
|---- |------| -----------|----- | ----- |
|  Anish   | anish@gmail.com   | person 1 | 2| 299 |
| Anish    | anish@gmail.com.  | person 2   | 1| 399 |
| ABC      | abc@gmail.com     | person 1   | 1| 299 |

One to many relation Orders -> items (It has multiple rows related to a single order)

I want to display all items for an event along with name, email, and phone. Please suggest to me the optimized mysql query for the same. I am using laravel 5.2.



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

lundi 23 octobre 2023

I have error while i copy laravel project from shared hosting to local

I want to copy laravel from shared hosting into my computer and run it from xampp server this is my road:

  1. i'm compress public_html folder from host
  2. download it and extract in xampp/htacess/project_name directory
  3. i was export database from server and import in local phpmyadmin
  4. delete vender directory and run composer install
  5. edit config/database.php with my local database information
  6. edit .env file with local information after all i run php artisan serve and i get this error screenshot avilable up there does anybody can help me

enter image description here



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

vendredi 20 octobre 2023

socketlabs not working without plainTextBody

This is working fine but when I am sending without plainTextBody then its not working I need to use without plainTextBody, I need to set just subject and htmlBody .

When I am working without plainTextBody then its not working.

$message->subject = "Simple Html file with text";
$message->plainTextBody = "This is the Plain Text Body of my message.";
$message->from = new EmailAddress("from@example.com");
$message->addToAddress(new EmailAddress("recipient1@example.com", "Recipient #1"));

//Get html content from a file
$pathToHtmlFile = __DIR__ .'../../../ExampleCode/Html/SampleEmail.html'; 
$message->htmlBody = file_get_contents($pathToHtmlFile);
 
//Send the message
$response = $client->send($message);

I am using this one https://www.socketlabs.com/api/ but I do not want to use plainTextBody in our project.



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

lundi 16 octobre 2023

i tired search in google, GPT even Bard nothing change in this code, laravel 5 problem

so i have this code in laravel 5

Customer::where('type', 1)->join('tb_customer_connector', 'tb_contact.id_customer', '=', 'tb_customer_connector.id_customer')
        ->join('tb_technology_tag', 'tb_customer_connector.id_product', '=', 'tb_technology_tag.id')
        ->where('tb_technology_tag.about', $id)
        ->get();

and simply this code i use for make a tabbar that make a fillter based on the technology.about but if a customer have two technology with same about it will make the customer show duoble because duoble connector

duplicate customer image

i already use district and groupBy and other but nothing changes



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

vendredi 13 octobre 2023

How to implement automatic code mapping UML in PHP

How to implement automatic code mapping UML in PHP. guide me which tool is perfect for us. My project running in Laravel 5.6, and I want to Codemapping all the code, So please suggest me solution.

How to implement automatic code mapping UML in PHP



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

jeudi 12 octobre 2023

How can loop and display studentId accoirding to the course_code

I want to display the students ID according to the batchId in table view. example for how I want.

EN01              EN02
12335             58965
45624             78956
46325             78599

This is my controller function.

if($request->courseId!="" && $request->batchId!="")
{
    $courseCodes = batches::where('course_id','=', $request->courseId)->where('id','=',$request->batchId)->get();
}else{
    $courseCodes = batches::where('course_id','=', $request->courseId)->get();
}


$course = courses::where('course_active','Yes')->where('course_active_flag','1')->get();
$users = User::all();

$tabliView = "";

$studentData = DB::table('students')
    ->select('studentId', 'batchId','courseId')
    ->where('courseId', $request->courseId);

if ($request->batchId != "") {
    $studentData->where('batchId', $request->batchId);
}

$studentData = $studentData->get();

And This is my table view with loop

<table class="table table-bordered text-nowrap border-bottom" id="basic-datatable">
    <thead>
        <tr>
            @foreach ($courseCode as $couscode)
                <th class="wd-15p border-bottom-0"></th>
            @endforeach
        </tr>
    </thead>
    <tbody>
        @foreach ($studentData as $student)
            <tr>
                @foreach ($courseCodes as $courseCode)
                    <td>
                        
                        @if ($student->batchId === $courseCode->id)
                            
                        @endif
                    </td>
                @endforeach
            </tr>
        @endforeach
    </tbody>
</table>

Now the result is coming like each course code same student Id is printing but each course code has a unique batchId. Please help me to fix this issue.



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

mardi 10 octobre 2023

Laravel (5.8) observer deleted is not working

I am using Laravel (5.8) and I need to delete a record from table A and then also table B. So I tried Observers, but it never fired the observer's deleted method.

I already used other methods like updating or updated, so I don't know why the deleted method is not firing.
I don't use soft delete, because I didn't make this database schema and I don't have authorities to modify that. But based on what I read from the document, it doesn't matter..right?

Here are my code.

  • Pay Controller.php
public function delete(Request $request, $idx){
    $payData = PaymentData::where('idx', $idx)->delete();
    return response()->json(['status' => true]);
}
  • PayObserver.php
public function deleted(PaymentData $paymentData)
{
        if ($paymentData->pay_type == "PA") {
            $app = AppData::where('oid', $paymentData->oid)->first();

            if (!empty($app)) {
                $app->delete();
            }
        }
}
  • AppServiceProvider.php
public function boot()
{
    \App\Models\PaymentData::observe(\App\Observers\PayObserver::class);
}

I also tried to add the observe statement to boot method in EventServiceProvider.php, but it wasn't working either.
I read the official document but couldn't find any clues..what did I miss?



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

lundi 9 octobre 2023

Laravel 10 Auth Login not working with custom Users table and column names

Info

I have custom name an columns for my Users table and I'm using MSSQL for database. My table is called 'TUsers' and for columns I'm using PascalCase so I have:

  • 'Email' instead of 'email'
  • 'Password' instead of 'password'
  • And all others like created_at, updated_at and remember_token

Registering works fine but there the user is automatically logged in with Auth::login()

The problem

Trying to login returns error "These credentials do not match our records." I have also tried to make a custom LoginController with my own function and I get the same issue using Auth::attempt

  • Tried using bcrypt() as well

What I've tried

I've added this to my User model

public $table = "TUsers";
protected $primaryKey = 'TUserID';

const EMAIL = 'Email';
const PASSWROD = 'Password';
const CREATED_AT = 'CreatedAt';
const UPDATED_AT = 'UpdatedAt';

public function getAuthPassword()
{
    return $this->Password;
}

protected $fillable = [
    'Name',
    'Email',
    'Password',
    'EmailVerifiedAt'
];

protected $hidden = [
    'Password',
    'RememberToken',
];

protected $casts = [
    'EmailVerifiedAt' => 'datetime',
    'Password' => 'hashed',
];

I've also made the following adjustments to auth.php

    'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
        'credentials' => [
            'email' => 'Email',
            'password' => 'Password'
        ]
    ],
],
    'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => 'PasswordResets',
        'expire' => 60,
        'throttle' => 60,
    ],
],

I've also tried mkaing a custom TUserProvider

<?php
namespace App\Providers;

use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\DB;

class TUsersProvider implements UserProvider
{
    public function retrieveById($identifier)
    {
        return DB::table('TUsers')->where('TUserID', $identifier)->first();
    }

    public function retrieveByToken($identifier, $token)
    {
        return DB::table('TUsers')->where('TUserID', $identifier)->where('RememberToken', $token)->first();
    }

    public function retrieveByCredentials(array $credentials)
    {
        // Retrieve a user by their credentials ('Email' and validate the 'Password')
        $user = DB::table('TUsers')->where('Email', $credentials['Email'])->first();

        if ($user && password_verify($credentials['Password'], $user->Password)) {
            return $user;
        }

        return null;
    }

    public function validateCredentials(Authenticatable $user, array $credentials)
    {
        return password_verify($credentials['Password'], $user->getAuthPassword());
    }

    public function updateRememberToken(Authenticatable $user, $token)
    {
        DB::table('TUsers')->where('TUserID', $user->getAuthIdentifier())->update([
            'RememberToken' => $token,
        ]);
    }
}

And added the following to AuthServiceProvider

   $this->app['auth']->provider('tusers', function ($app, array $config) {
        return new TUsersProvider($app['hash'], $config['model']);
    });

And updated in auth.php the 'provider' parameter under guards.web to 'tusers'.

But then I get the error:

Illuminate\Auth\SessionGuard::__construct(): Argument #2 ($provider) must be of type Illuminate\Contracts\Auth\UserProvider, null given, called in /var/www/html/clients/markj/iatse-new/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 127



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

Pusher error: auth_key should be a valid app key

guys I did try work with edit and when I click on submit I have this error, but the changes was done and I am guessing why I have this issue

Pusher error: auth_key should be a valid app key .

This is my broadcasting.php

'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => false,
            'useTLS' => false,
            'scheme' => 'http',
            // 'host' => env('PUSHER_HOST'),
            // 'port' => env('PUSHER_PORT', 6379),
            'scheme' => env('PUSHER_SCHEME', 'http'),
            'curl_options' => [
                CURLOPT_SSL_VERIFYHOST => 0,
                CURLOPT_SSL_VERIFYPEER => 0,
            ]
          
        ],
    ],

And this .env file

PUSHER_APP_ID=995591
PUSHER_APP_KEY=644a4ac1988060882370
PUSHER_APP_SECRET=739696537f4fb23b8fcd
PUSHER_APP_CLUSTER=ap1
PUSHER_PORT=6379
PUSHER_SCHEME=http
PUSHER_HOST_PROXY=${HOST}
PUSHER_PATH_PROXY='/websockets'
PUSHER_PORT_PROXY=443
PUSHER_HOST=127.0.0.1
MIX_PUSHER_HOST=${HOST}


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

vendredi 6 octobre 2023

Why laravel users get looged out everytime I deploy an app to heroku

We are using Laravel 5 and spatie-permissions package. Every time we commit something to the master branch, everything gets rebuilt.

Could that be the cause of invalidating all user sessions?

PHP version is 7.4.33. We used auth0 for user login earlier, should we remove it from composer.json?

I've attached the log below

-----> Building on the Heroku-20 stack  
-----> Using buildpacks:  
       1. heroku/php  
       2. https://github.com/harrylewis/heroku-buildpack-potrace.git  
-----> PHP app detected  
-----> Bootstrapping...  
  
 !     WARNING: Your 'composer.lock' is out of date!  
 !   
 !     The 'composer.lock' file in your project is not up to date with  
 !     the main 'composer.json' file. This may result in installation  
 !     of incorrect packages or package versions.  
 !   
 !     The lock file is required in order to guarantee reliable and  
 !     reproducible installation of dependencies across systems and  
 !     deploys. It must always be kept in sync with 'composer.json'.  
 !   
 !     Whenever you change 'composer.json', ensure that you perform  
 !     the following steps locally on your computer:  
 !     1) run 'composer update'  
 !     2) add all changes using 'git add composer.json composer.lock'  
 !     3) commit using 'git commit'  
 !   
 !     Ensure that you updated the lock file correctly, and that you  
 !     ran 'git add' on both files, before deploying again.  
 !   
 !     Please remember to always keep your 'composer.lock' updated in  
 !     lockstep with 'composer.json' to avoid common problems related  
 !     to dependencies during collaboration and deployment.  
 !   
 !     Please refer to the Composer documentation for further details:  
 !     https://getcomposer.org/doc/  
 !     https://getcomposer.org/doc/01-basic-usage.md  
  
-----> Preparing platform package installation...  
-----> Installing platform packages...  
       - php (7.4.33)  
       - ext-oauth (2.0.7)  
       - ext-memcached (3.2.0)  
       - ext-imagick (3.7.0)  
       - ext-ftp (bundled with php)  
       - apache (2.4.57)  
       - composer (2.6.4)  
       - nginx (1.24.0)  
       - ext-gd (bundled with php)  
       NOTICE: detected userland polyfill packages for PHP extensions  
       NOTICE: now attempting to install native extension packages  
       Installing extensions provided by symfony/polyfill-mbstring:  
       - ext-mbstring...   
       Installing extensions provided by symfony/polyfill-iconv:  
       - ext-iconv...   
       Installing extensions provided by symfony/polyfill-ctype:  
       - ext-ctype...   
  
 !     WARNING: Your selected PHP version has reached end-of-life  
 !   
 !     No updates or security fixes have been provided for your PHP  
 !     version series by the PHP Group since 2022-11-28.  
 !   
 !     It is strongly recommended you update your app to a version of  
 !     PHP with "active support" status immediately to ensure you get  
 !     the latest bugfixes and security updates each time you deploy.  
 !   
 !     You may check the list of versions supported by the PHP Group  
 !     and their EOL dates here: http://php.net/supported-versions.php  
 !   
 !     For a list of supported runtimes & extensions on Heroku, please  
 !     refer to: https://devcenter.heroku.com/articles/php-support  
  
-----> Installing dependencies...  
       Composer version 2.6.4 2023-09-29 10:54:46  
       Installing dependencies from lock file  
       Verifying lock file contents can be installed on current platform.  
       Warning: The lock file is not up to date with the latest changes in composer.json.   You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.  
       Package operations: 135 installs, 0 updates, 0 removals  
         - Installing kylekatarnls/update-helper (1.2.1): Extracting archive  
         - Installing symfony/polyfill-ctype (v1.26.0): Extracting archive  
         - Installing vlucas/phpdotenv (v2.6.9): Extracting archive  
         - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive  
         - Installing symfony/css-selector (v5.4.11): Extracting archive  
         - Installing tijsverkoyen/css-to-inline-styles (2.2.5): Extracting archive  
         - Installing symfony/polyfill-php72 (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive  
         - Installing symfony/var-dumper (v4.4.46): Extracting archive  
         - Installing symfony/routing (v4.4.44): Extracting archive  
         - Installing symfony/process (v4.4.44): Extracting archive  
         - Installing symfony/polyfill-php73 (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive  
         - Installing symfony/polyfill-intl-idn (v1.26.0): Extracting archive  
         - Installing symfony/deprecation-contracts (v2.5.2): Extracting archive  
         - Installing symfony/mime (v5.4.13): Extracting archive  
         - Installing symfony/http-foundation (v4.4.46): Extracting archive  
         - Installing symfony/http-client-contracts (v2.5.2): Extracting archive  
         - Installing symfony/event-dispatcher-contracts (v1.1.13): Extracting archive  
         - Installing symfony/event-dispatcher (v4.4.44): Extracting archive  
         - Installing psr/log (1.1.4): Extracting archive  
         - Installing symfony/debug (v4.4.44): Extracting archive  
         - Installing symfony/error-handler (v4.4.44): Extracting archive  
         - Installing symfony/http-kernel (v4.4.46): Extracting archive  
         - Installing symfony/finder (v4.4.44): Extracting archive  
         - Installing psr/container (1.1.2): Extracting archive  
         - Installing symfony/service-contracts (v2.5.2): Extracting archive  
         - Installing symfony/console (v4.4.45): Extracting archive  
         - Installing symfony/polyfill-iconv (v1.26.0): Extracting archive  
         - Installing doctrine/lexer (1.2.3): Extracting archive  
         - Installing egulias/email-validator (3.2.1): Extracting archive  
         - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive  
         - Installing paragonie/random_compat (v9.99.100): Extracting archive  
         - Installing ramsey/uuid (3.9.6): Extracting archive  
         - Installing psr/simple-cache (1.0.1): Extracting archive  
         - Installing opis/closure (3.6.3): Extracting archive  
         - Installing symfony/translation-contracts (v2.5.2): Extracting archive  
         - Installing symfony/translation (v4.4.45): Extracting archive  
         - Installing nesbot/carbon (1.39.1): Extracting archive  
         - Installing monolog/monolog (1.27.1): Extracting archive  
         - Installing league/mime-type-detection (1.11.0): Extracting archive  
         - Installing league/flysystem (1.1.10): Extracting archive  
         - Installing ralouphie/getallheaders (3.0.3): Extracting archive  
         - Installing psr/http-message (1.0.1): Extracting archive  
         - Installing guzzlehttp/psr7 (1.9.0): Extracting archive  
         - Installing guzzlehttp/promises (1.5.2): Extracting archive  
         - Installing guzzlehttp/guzzle (6.5.8): Extracting archive  
         - Installing laravel/slack-notification-channel (v1.0.3): Extracting archive  
         - Installing php-http/promise (1.1.0): Extracting archive  
         - Installing php-http/httplug (v1.1.0): Extracting archive  
         - Installing php-http/guzzle6-adapter (v1.1.1): Extracting archive  
         - Installing psr/http-factory (1.0.1): Extracting archive  
         - Installing zendframework/zend-diactoros (2.2.1): Extracting archive  
         - Installing symfony/http-client (v5.4.13): Extracting archive  
         - Installing lcobucci/jwt (3.4.6): Extracting archive  
         - Installing nexmo/client-core (1.8.1): Extracting archive  
         - Installing nexmo/client (1.9.1): Extracting archive  
         - Installing laravel/nexmo-notification-channel (v1.0.1): Extracting archive  
         - Installing erusev/parsedown (1.7.4): Extracting archive  
         - Installing dragonmantank/cron-expression (v2.3.1): Extracting archive  
         - Installing doctrine/inflector (1.4.4): Extracting archive  
         - Installing laravel/framework (v5.7.29): Extracting archive  
         - Installing firebase/php-jwt (v5.5.1): Extracting archive  
         - Installing auth0/auth0-php (5.7.0): Extracting archive  
         - Installing auth0/login (5.4.0): Extracting archive  
         - Installing automattic/woocommerce (3.1.0): Extracting archive  
         - Installing aws/aws-crt-php (v1.0.2): Extracting archive  
         - Installing mtdowling/jmespath.php (2.6.1): Extracting archive  
         - Installing aws/aws-sdk-php (3.238.1): Extracting archive  
         - Installing aws/aws-sdk-php-resources (0.3.0): Extracting archive  
         - Installing clue/stream-filter (v1.6.0): Extracting archive  
         - Installing symfony/dependency-injection (v4.4.44): Extracting archive  
         - Installing symfony/polyfill-php81 (v1.26.0): Extracting archive  
         - Installing symfony/filesystem (v5.4.13): Extracting archive  
         - Installing symfony/config (v4.4.44): Extracting archive  
         - Installing dzunke/slack-bundle (2.6.0): Extracting archive  
         - Installing easypost/easypost-php (3.6.0): Extracting archive  
         - Installing facebook/graph-sdk (5.7.0): Extracting archive  
         - Installing fideloper/proxy (4.4.2): Extracting archive  
         - Installing gertjanspriensma/etsy-php (dev-master 95f0cb8): Extracting archive  
         - Installing http-interop/http-factory-guzzle (1.2.0): Extracting archive  
         - Installing mmucklo/inflect (v0.3.0): Extracting archive  
         - Installing zendesk/zendesk_api_client_php (v2.2.15): Extracting archive  
         - Installing huddledigital/zendesk-laravel (v3.7): Extracting archive  
         - Installing jakub-onderka/php-console-color (v0.2): Extracting archive  
         - Installing jeremy-dunn/php-fedex-api-wrapper (3.0): Extracting archive  
         - Installing nikic/php-parser (v4.15.1): Extracting archive  
         - Installing jakub-onderka/php-console-highlighter (v0.4): Extracting archive  
         - Installing dnoegel/php-xdg-base-dir (v0.1.1): Extracting archive  
         - Installing psy/psysh (v0.9.12): Extracting archive  
         - Installing laravel/tinker (v1.0.10): Extracting archive  
         - Installing psr/http-client (1.0.1): Extracting archive  
         - Installing markbaker/matrix (3.0.0): Extracting archive  
         - Installing markbaker/complex (3.0.1): Extracting archive  
         - Installing myclabs/php-enum (1.8.4): Extracting archive  
         - Installing maennchen/zipstream-php (2.2.1): Extracting archive  
         - Installing ezyang/htmlpurifier (v4.16.0): Extracting archive  
         - Installing phpoffice/phpspreadsheet (1.25.2): Extracting archive  
         - Installing maatwebsite/excel (3.1.25): Extracting archive  
         - Installing mixpanel/mixpanel-php (2.10.0): Extracting archive  
         - Installing myparcelnl/sdk (v3.1.7): Extracting archive  
         - Installing omnisend/php-sdk (1.2): Extracting archive  
         - Installing paypal/rest-api-sdk-php (1.14.0): Extracting archive  
         - Installing paragonie/constant_time_encoding (v2.6.3): Extracting archive  
         - Installing phpseclib/phpseclib (3.0.16): Extracting archive  
         - Installing php-amqplib/php-amqplib (v3.3.1): Extracting archive  
         - Installing php-http/message-factory (v1.0.2): Extracting archive  
         - Installing phpclassic/php-shopify (v1.2.5): Extracting archive  
         - Installing picqer/sendcloud-php-client (v2.7.0): Extracting archive  
         - Installing symfony/yaml (v4.4.45): Extracting archive  
         - Installing predicthq/address-formatter-templates (v1.0.0): Extracting archive  
         - Installing mustache/mustache (v2.14.2): Extracting archive  
         - Installing predicthq/address-formatter (v1.1.0): Extracting archive  
         - Installing printnode/printnode-php (2.0.0-rc1): Extracting archive  
         - Installing psr/cache (1.0.0): Extracting archive  
         - Installing starkbank/ecdsa (0.0.5): Extracting archive  
         - Installing sendgrid/php-http-client (3.14.4): Extracting archive  
         - Installing sendgrid/sendgrid (7.11.5): Extracting archive  
         - Installing symfony/polyfill-uuid (v1.26.0): Extracting archive  
         - Installing symfony/options-resolver (v5.4.11): Extracting archive  
         - Installing php-http/message (1.13.0): Extracting archive  
         - Installing php-http/discovery (1.14.3): Extracting archive  
         - Installing php-http/client-common (1.11.0): Extracting archive  
         - Installing jean85/pretty-package-versions (2.0.5): Extracting archive  
         - Installing sentry/sentry (2.5.2): Extracting archive  
         - Installing sentry/sdk (2.2.0)  
         - Installing sentry/sentry-laravel (1.9.0): Extracting archive  
         - Installing setasign/fpdi (v2.3.6): Extracting archive  
         - Installing thecodingmachine/safe (v1.3.3): Extracting archive  
         - Installing setono/post-nord-php-sdk (v1.2.0): Extracting archive  
         - Installing graham-campbell/guzzle-factory (v3.0.4): Extracting archive  
         - Installing spatie/dropbox-api (1.21.0): Extracting archive  
         - Installing spatie/laravel-permission (2.38.0): Extracting archive  
         - Installing stripe/stripe-php (v7.128.0): Extracting archive  
         - Installing tecnickcom/tcpdf (6.5.0): Extracting archive  
       Package dzunke/slack-bundle is abandoned, you should avoid using it. No replacement was suggested.  
       Package facebook/graph-sdk is abandoned, you should avoid using it. No replacement was suggested.  
       Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.  
       Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.  
       Package laravel/nexmo-notification-channel is abandoned, you should avoid using it. Use laravel/vonage-notification-channel instead.  
       Package paypal/rest-api-sdk-php is abandoned, you should avoid using it. No replacement was suggested.  
       Package predicthq/address-formatter is abandoned, you should avoid using it. No replacement was suggested.  
       Package predicthq/address-formatter-templates is abandoned, you should avoid using it. No replacement was suggested.  
       Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.  
       Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.  
       Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.  
       Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.  
       Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.  
       Generating optimized autoload files  
       Class FedEx\Tests\ValidationAvailabilityAndCommitmentService located in ./vendor/jeremy-dunn/php-fedex-api-wrapper/tests/FedEx/Tests/ValidationAvailabilityAndCommitmentServiceTest.php does not comply with psr-4 autoloading standard. Skipping.  
       > Illuminate\Foundation\ComposerScripts::postAutoloadDump  
       61 packages you are using are looking for funding.  
       Use the `composer fund` command to find out more!  
-----> Preparing runtime environment...  
-----> Checking for additional extensions to install...  
-----> Potrace loaded app detected  
-----> Installing potrace  
potrace-1.16.linux-x86_64/  
potrace-1.16.linux-x86_64/README-WIN  
potrace-1.16.linux-x86_64/potrace.1  
potrace-1.16.linux-x86_64/placement.pdf  
potrace-1.16.linux-x86_64/README  
potrace-1.16.linux-x86_64/NEWS  
potrace-1.16.linux-x86_64/ChangeLog  
potrace-1.16.linux-x86_64/mkbitmap.1  
potrace-1.16.linux-x86_64/mkbitmap  
potrace-1.16.linux-x86_64/AUTHORS  
potrace-1.16.linux-x86_64/potrace  
potrace-1.16.linux-x86_64/COPYING  
-----> Discovering process types  
       Procfile declares types -> web, worker  
-----> Compressing...  
       Done: 186.1M  
-----> Launching...  
       Released v318  
       https://my-app.herokuapp.com/ deployed to Heroku  
This app is using the Heroku-20 stack, however a newer stack is available.  
To upgrade to Heroku-22, see:  
https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack


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

jeudi 5 octobre 2023

After change the password login is not working using Laravel

I created the client register and the password change function. When I register the client with the password that password and username are working without any issues. But when I change the password and log in with a new password always says the password is incorrect.I can't understand what is the issue please help me to solve this issue.

This is my register code

public function store(Request $request, client $client)
    {
        
        $token = $request->input('g-recaptcha-response');

        if(strlen($token)>0)
        {
        
            $result = client::where('email', $request->email)->first();
    
            if (!empty($result))
            {
                return Redirect::back()->with('errmessage','The registered email address is already in use. Please contact the website administrator or request a password reset');
            }
    
            $client->clie_id = $request->email;
            $client->clie_fname = $request->clie_fname;
            $client->clie_lname = $request->clie_lname;
            $client->clie_company = $request->clie_company;
            $client->password = Hash::make($request->password);
            $client->email = $request->email;
            $client->clie_telephone = $request->clie_telephone;
            $client->clie_fax = $request->clie_fax;
            $client->clie_address1 = $request->clie_address1;
            $client->clie_address2 = $request->clie_address2;
            $client->clie_address3 = $request->clie_address3;
    
            $client->clie_city = $request->clie_city;
            $client->clie_state = $request->clie_state;
            $client->clie_postcode = $request->clie_postcode;
            $client->clie_country = $request->clie_country;
    
            $client->clie_newslatter= $request->clie_newslatter;
    
            $client->save();
    
            return Redirect::back()->with('message','Account Created Successfully. You may now login using the email you registered with and your password');
            
        }else{
            return redirect()->back()->with('warmessage','Please make sure your not a robot');
        }
    }

This is my password change function

public function PasswordChange(Request $request)
    {
        
        //dd($request->clientId);
        
        $token = $request->input('g-recaptcha-response');

        if(strlen($token)>0)
        {
            $user = Client::where('email', $request->clientId)->first();

            if (!$user) {
                return redirect()->back()->with('error', 'User not found.');
            }
            
            if (!Hash::check($request->old_password, $user->password)) {
                return redirect()->back()->with('error', 'The old password is incorrect.');
            }
            
            $user->update([
                'password' => Hash::make($request->password)
            ]);
            
            // Clear the user's session to ensure the new password takes effect
            Auth::guard('client')->logout();
        
            return redirect()->route('Home')->with('message','Password is Successfully changed.');
            
        }else{
            return redirect()->back()->with('message','Please make sure your not a robot');
        }

        // return redirect()->route('home')->with('success', 'Password changed successfully.');
    }

My login function

public function login(Request $request)
    {
        
        //dd($request->password);
        
        // Retrieve the user record by email
        $user = client::where('email', $request->email)->first();
        
        Log::info('Login attempt:', [
            'email' => $request->email,
            'entered_org_password' => $request->password,
            'entered_password' => Hash::make($request->password),
            'hashed_password' => $user->password,
        ]);
        

        if(Auth::guard('client')->attempt(['email'=>$request->email,'password'=>$request->password],$request->remember))
        {
          return redirect('/')->withMessage('Successfully Logged In');
        }else{
            return redirect(route('Client_Login'))->with('Error');
        }

        return redirect()->back()->withInput($request->only('email'));
    }

This is my log data when login with a new password

After Registering this the records for login.

[2023-10-05 08:34:06] local.INFO: Login attempt: {"email":"james@gmail.com","entered_org_password":"123456789","entered_password":"$2y$10$1mR2dKLEJAHvv0BCQoCfZeLP5Ugq4ngTvHD4/RFDtXp.asB7AJKF.","hashed_password":"$2y$10$Jxm/cd25Xpe4i8ljfDV98uIICszGb61pV6PtcwuhqHayjujWsOejm"} 

After changing the password and login records

[2023-10-05 08:35:21] local.INFO: Login attempt: {"email":"james@gmail.com","entered_org_password":"123456789123","entered_password":"$2y$10$49D4RS5aNWwl8xtnWOGeQ.wuT2Ozipz4O1yAtmJQAsmjoZiLQb3b.","hashed_password":"$2y$10$.dj8Egmzr0JDs7IlmMfZ2ultD5Srp5YTo0Wxi0WHmxscc0P1cpS3u"} 


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

How to update 5000+ records in a set of 200s in laravel?

I have a total of approximately 8000+ records. I want to update them in a set of 200s, so that the site which I am working on, doesn't go down due to excessive queries execution. Right now I am not able to do that.

This is my code:

$totalRecords = DB::table('domain_authority_score_update')->where('update_flag', 0);
$reduceRecords = $totalRecords->take(200)->get();

I have used foreach to update all records.

foreach($reduceRecords as $val){
}

I have tried to update them by using for() loop and also do-while() loop, but it didn't give me the expected result.

I have also tried using chunk(). But I did not succeed.

Any help would be appreciated. Thanks in advance.



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

mercredi 4 octobre 2023

Laravel Post & Comments relation, only post author can delete the comment. but the user who made comment can edit and delete also

I don't have any idea how to do it. if anybody knows about it. let me know. I think its some thing relevant to validation. plz guide me.

only post author can delete the comment. but the user who made comment can edit and delete also



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