mardi 2 février 2021

Laravel S3 exists() function taking too much time to check file exists or not

I am using S3 bucket to save images.

Now I want to check if image exists then show from path 1 otherwise show from path 2.

But exists method taking approx 5 seconds minimum to check single image.

Did I have to do something additional ?

function getImagePath($type = 'sm')
{

    $imageURL = $this->rootURL. '/' .$type .'-'. $this->imageName;

    if (Storage::disk('s3')->exists($imageURL)) {  // -> This line taking too much time.
        return $imageURL;
    }else{
        return config('constant.productThumbnail') . $this->imageName;
    }
}


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

check the date field value 'month and year' is in given date

I have tow tables meeting_dump and prospects_audit table

I want to get the value meeting id for the prospects based on prospects id.I want to check 3 conditions in query

  1. meeting_dump.date_start start date month is in two given months ($dates_between=['2021-02-01','2021-02-02']) if I give 2021-02-01 I want to check the meeting_dump.date_start is in 2021-02 and get the parent_id

2.after_value string should be MGl 3.meeting_dump.status.status should be 'Held'

my query is

$type='prospects';
$meeting_ids=DB::table($type.'_audit_dump')->leftJoin('meeting_dump','meeting_dump.parent_id',$type.'_audit_dump.parent_id')->where('field_name','=','lead_stage_c')
                 ->where(function ($query) use ($dates_between){
            return $query->orWhere(DB::raw(date('m',strtotime('meeting_dump.date_start'))),'=',date("m", strtotime($dates_between[0])))->orWhere(DB::raw(date('m',(strtotime('meeting_dump.date_start')))),'=',date("m", strtotime($dates_between[1])));
             })
             ->where('after_value_string','=','MGL')->where('meeting_dump.status','Held')->pluck($type.'_audit_dump.parent_id')->toArray();

dd ::getQueryLog() displays

select "prospects_audit_dump"."parent_id" from "prospects_audit_dump" left join "meeting_dump" on "meeting_dump"."parent_id" = "prospects_audit_dump"."parent_id" where (02 = 02 or 02 = 02) and "after_value_string" = 'MGL' and field_name='lead_stage_c' and "meeting_dump"."status" = 'Held';

and getting wrong data

how to check the month of the date start is in give date



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

Compare date time in Laravel eloquent

I have start and end date time column in database

start_date             end_date             contact
2021-01-25 17:30:00    2021-01-25 20:30:00   xxxxxxxxx
2021-01-27 17:30:00    2021-01-28 19:30:00   xxxxxxxxx

Now i'm trying to get records which exists between these two date time, it should match mobile number also.I'm using below query but it is not filtering record

   $date = date('Y-m-d H:i:s', strtotime($request->date));
   $contact_number=$request->contact_number;

$event=Event::where(function ($query)use($date,$contact_number){
    $query->where('start_date', '>=', $date)->where('end_date', '<=', $date);})->where('contact',$contact_number)->paginate(5);  


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

lundi 1 février 2021

Invalid argument supplied for foreach() in cron

In laravel I have scheduled the cron by passing date as parameter.While passing date with minimal data cron executed successfully.but getting Invalid argument supplied for foreach() for the date with multiple rows. prospectsDump::cron is my cron .Im executing this cron as

project_folder>php artisan prospectsDump::cron

searched and find

  php -d register_argc_argv=1 artisan schedule:run > '/dev/null' 2>&1 &

but how to change register_arc in my cron



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

Laravel : Can't access value from an array

So , I have wrote a Common Helper function , which when called should give me a variable set with either 1 or 0 , and then proceed to the rest of code.

function getPfWages($earning_id,$payrunid)
{
    $name = Earning::select('consider_epf_contribution')
        ->where('id',$earning_id)
        ->where('consider_epf_contribution','1')
        ->first();

    dump($name);

    if($name=='1') {
        $TotalAmount = PayrunsEmployeeDetails::where('earning_id',$earning_id)
            ->where('payrun_id',$payrunid)
            ->sum('payamount');

        return $TotalAmount;

    } else {
        return 0;
    }
}

The dump function shows this output : The var dump looks like this

But , when I try to access the $name array by an offset 'consider_epf_contribution' , it throws an error of "Trying to access array offset on value of type null". I cant figure out why this is happening.

I have also tried "toArray()" , "get()" and "sum()" but same errors are thrown while accessing the array. This is my first ever Laravel project.

"Trying to get property 'consider_epf_contribution' of non-object" throws me this error when i try $name->consider_epf_contribution.

-TIA ~regards



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

Filter data with laravel-vue-pagination

I'm trying to filter data by name in a table like

 <form @submit.prevent="search" @keydown="form.onKeydown($event)">
            <div class="form-group">
             <label>Name</label>
            <input name="name" v-model="form.amount" placeholder="Enter Name">
            </div>
        </form>
    
    
    
        <div class="card-body p-0">
                  <table class="table table-striped">
                <thead>
                  <tr>
                    <th scope="col">Name</th>
                    <th scope="col">Amount</th>
                    <th scope="col">Actions</th>
                  </tr>
                </thead>
                <tbody>
                  <table-row @listRemoved="removeList" v-for="(list, index) in UserData.data" :list="list" :index="index" :key="list.id"></table-row>
                </tbody>
              </table>
                </div>
                <div class="card-footer">
                      <pagination :data="UserData" @pagination-change-page="getResults">
                        <span slot="prev-nav">&lt; Previous</span>
                        <span slot="next-nav">Next &gt;</span>
                      </pagination>
                  </div>
              </div>
            </div>
        
         data(){
              return {
                UserData: {},
                form: new Form({
                  name: '',
                }),
              }
            },
 mounted(){
       this.loadAllData();
    },
 loadAllData(){
       const header = {
              'Authorization': 'Bearer ' + this.getLoginUserData,
         };
        axios.get("/api/user",{headers: header}).then(({ data }) => (this.userData = data));
      },
 search(){
         this.form.post(`/api/search-user`,{headers: this.header()}).then((response) =>{
            this.userData = null;
            this.userData = response.data;
          })
      },
 getResults(page){
       const header = {
              'Authorization': 'Bearer ' + this.getLoginUserData,
         };
        axios.get('/api/user?page=' + page , {headers: header})
                .then(response => {
                    this.userData = response.data;
                });
      },

Controller:

public function index(){
        $user = User::paginate(5);
        return response()->json($user,200);
    }

 public function search(Request $request)
    {
        $user = User::where('name','LIKE',"%{$request->name}%")->paginate(5);
        return response()->json($user,200);
    }

on mounted event loadAllData event is called which loads all data through index function of controller and when i search then the filtered data is searched through search method. But when i click on pagination links then it shows all the unfiltered data i.e. complete result without filter. But i also want pagination to work on searched data.

Any help is highly appreciated.



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

google not indexed and webcache also not working

The main problem is my website's pages in google cached are not complete, they have no data, because of XHR errors, here are some details:

I implemented my website using AngularJs and laravel, It works correctly on any browsers and locations I've tested. Google says, "Google Search Engine sees exactly what modern browsers display", but my website has not indexed correctly yet, so there is a problem in my codes!

've been struggling with google to introduce my website's pages completely to Google, but all I've gotten is pages with non-filled controls and without any data that loads via Angular. When I check my website on Google Live Test, I get this kind of errors in Page Resources: "Couldn't be loaded" Some of these errors are related to images that don't matter right now, but the emergency problem is that most of XHRs couldn't be loaded! There is no detail to know what is the exact issue, but when I'd checked my website cached pages on google I saw this error on developer tools:

When i tried see webcache it only appears empty page.



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