jeudi 12 mai 2022

How to load view file from another root directory in Laravel 5.8

I want to load view file from another root directory. Example : return view('http://localhost/laravelApp/view/products', $data);

http://localhost/laravel/view this is my another view file directory and 'products' is view file name and my laravel project directory is laravelApp. My laravel version 5.8



via Chebli Mohamed

mercredi 11 mai 2022

Cache clear probem in Larave

I have a problem. I am download project from hosting. now when I run the project this error shows. pic attached. I think this is cache problem, I clear cache, view, but still same issue.



via Chebli Mohamed

mardi 10 mai 2022

How to get name property from select option in laravel

I want to search from input field but want to get the property from the select option. Like I want mobile number to be searched from DB , but when i select mobile from select option then it should be search and if i select email then inside the input field i will post email and will select the email from select option then want to search. Here I have done some coding.

Blade file code

<select name="option" class="col-sm-4 form-control mg-md-l-2">
    <option value="">Select</option>
    <option value="cc" name="cc">Customer Code</option>
    <option value="cname" name="cname">Company Name</option>
    <option value="email" name="email">Email</option>
    <option value="mobile" name="mobile">Phone</option>
</select>
<div class="col-1"></div>
<input type="text" class="col-sm-6 form-control" placeholder="Type here" name="">

Here the controller code

$user_id= Auth::user()->id;
    $sale = $request->get('sales_id');
    $priority = $request->get('priority');
    $cc = $request->get('cc');
    $cname = $request->get('cname');
    $email = $request->get('email');
    $mobile = $request->get('mobile');
    $from_date = $request->input('from_date');
    $to_date = $request->input('to_date');
    if (empty($from_date)) {
        $from_date = '2019-01-01 00:00:00';
    } else {
        $from_date = $from_date . ' 00:00:00';
    }
    if (empty($to_date)) {
        $to_date = date('Y-m-d H:i:s');
    } else {
        $to_date = $to_date . ' 23:59:59';
    }
    if ($sale || $priority || $cname || $email || $mobile || $cc) {
        $customers = \DB::table('field_customers as u')
                ->where('u.cc', 'LIKE', "%{$cc}%")
                ->where('u.sales_id', 'LIKE', "%{$sale}%")
                ->where('u.priority', 'LIKE', "%{$priority}%")
                ->where('u.cname', 'LIKE', "%{$cname}%")
                ->where('u.email', 'LIKE', "%{$email}%")
                ->where('u.mobile', 'LIKE', "%{$mobile}%")
                ->whereBetween('u.followup', [$from_date, $to_date])
                ->orderBy('u.followup', 'DESC')
                ->paginate(10);
    }
    else{
        $customers = DB::table('field_customers')  
        ->orderBy('id', 'DESC')
        ->paginate(20);
    }

Here what I want enter image description here



via Chebli Mohamed

how to call one api to another api in laravel using wamp server?

in Web.php

Route::get('/apiforsales', [LeadController::class, 'apiforsales']); //this working fine.

Route::get('/apicheck', [LeadController::class,'apicheck123']);

LeadController.php

public function apiforsales(Request $req)
{
 $results = DB::select( DB::raw(" select id,name,implement,lead_type,number,district,state FROM comman_datas where state = '$req->state' and district= '$req->district' and status = '0'  "));   
 return $results;
}

public function apicheck123(Request $req)
{
    $response = Http::get("http://127.0.0.1:8000/apiforsales?state=".$req->state."&district=".$req->district);
    $jsondata= $response->getBody();
    $data =json_decode($jsondata, true);
    return $data;
}

In postman calling a api

http://127.0.0.1:8000/apiforsales?state=Karnataka&district=Bengaluru ..///working fine.

http://127.0.0.1:8000/apicheck?state=Karnataka&district=Bengaluru ..///it will loading to much time not giving a exact cause of



via Chebli Mohamed

lundi 9 mai 2022

Swift_TransportException: Expected response code 250 but got code "", with message "" in AbstractSmtpTransport.php:383

I have a laravel application that has been sending emails for Years now. Recently, emails have been failing to send. When I check the failed_jobs table, below is the error message:

Swift_TransportException: Expected response code 250 but got code "", with message "" in 
/apps/www/ccc.xxxx.com/public_html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383

Below are things I have attempted:

  • composer dump-autoload
  • php artisan config:cache
  • php artisan config:clear
  • php artisan queue:restart
  • restarted supervisor
  • Ensure username and password is correct in .env file
  • I have connected to the mail box successfully and able to send email to anyone

Below is the .env config

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=g.blah@balh.com
MAIL_PASSWORD=Va#@2016
MAIL_ENCRYPTION=TLS

What can be the issue and how to fix this ?



via Chebli Mohamed

Twitter api returning html response as error

My code

$connection = new TwitterOAuth(SOCIOMATIC_HFW_API_KEY, SOCIOMATIC_HFW_API_SECRET);
$connection->setTimeouts(1000, 1000);
$request_token = $connection->oauth("oauth/request_token", array("oauth_callback" => 'env('TWITTER_CALLBACK_URL')'));

Response in html :

Abraham\TwitterOAuth\TwitterOAuthException
<!DOCTYPE html>
    <html lang="en" class="dog">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
            <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
            <title>Twitter / ?</title>
            <meta name="version" content="1">
            <link href="https://abs.twimg.com/favicons/favicon.ico" rel="shortcut icon" type="image/x-icon"> 
            <link rel="stylesheet" href="https://abs.twimg.com/errors/fullscreen_errors-


via Chebli Mohamed

dimanche 8 mai 2022

How to upload TAR.GZ file from Laravel

I am trying to send a tar.gz file from Laravel as a response, but it is not working properly. What is the error in the code? Here $filepath is the absolute path to the tar.gz file.

if(file_exists($filepath)) {
        $file = File::get($filepath);
        $response = Response::make($file, 200);
        $response->header('Content-Type', mime_content_type($filepath));
        $response->header('Content-Length', filesize($filepath));
        $response->header('Pragma', 'public');
        $response->header('Content-Disposition', 'attachment; filename="sample.tar.gz"');

        return $response;
        
    }
    else {
        return $this->response->array(array('error' => 'Could not be downloaded, try again'));
    }


via Chebli Mohamed