vendredi 15 janvier 2021

Laravel database connections being kept open

I have this Laravel app that keeps 50 ish processes running sleep command and every time I kill those they keep coming back.

I have no idea where to look first and how to resolve this issue. I simply don't want this many connections being open on the server.

I tried to delete all failed_jobs from the table, there are no jobs to attempt.

The laravel scheduler runs every minute to make the queue work in order to send the mails.

enter image description here



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

jeudi 14 janvier 2021

Laravel accessing image in Storage folder on WAMP

Laravel accessing image in Storage folder is working on live server but it is not working on the local server (below is the error)

enter image description here



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

I'm getting Laravel Exception

I'm working on a project and I'm using dompdf to create and render PDF.

"No block-level parent found. Not good"

I'm getting this error. Screenshot also attched

In development it works fine. But when i create PDF i got strange error.

Any idea what is the reason behind this? and how to fix?



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

Laravel Parse Data By ID Foreach Loop From Different Table

so I would like to get each data from two different table and display in on my view according to the ID of each row on the view table. However, I am stuck as I was not able to display the data according to their ID and now it is showing all my rows from the other two tables as follow:

enter image description here

Table Event

Table Event_Details

Table Event_Participants

Here is my table section within the view:

<table class="table table-hover table-borderless">
        <tr>
            <th class="text-center" width="10px">No</th>
            <th width="250px">Event Name & Venue</th>
            <th width="120px">Event Start</th>
            <th width="120px">Event End</th>
            <th width="80px" class="text-center">Category</th>
            <th width="80px">Participant</th>
        </tr>
        @foreach ($events as $event)
            <tr>
                <td class="text-center"></td>
                <td> <br/>
                 
                    Venue: 
                    @foreach ($event_details as $event_detail)
                    
                    @endforeach
                 
                
                
                </td>
                <td> </br>  </td>
                <td> </br> </td>
                <td class="text-center">
                    @switch($event->event_category)
                    @case($event->event_category==1)
                        HQ-Based
                        @break
                        @case($event->event_category==2)
                        Stakeholder
                        @break
                        @case($event->event_category==3)
                        Webinar
                        @break
                        @case($event->event_category==4)
                        Online Training
                        @break
                    @default
                @endswitch    
                
                </td>
                <td class="text-center">
                 
                    <ol>
                        @foreach ($event_participants as $parti)

                            <li>
                                
                    
                         
                             @foreach ($users->where('id', $parti->user_id) as $user)
                                 
                             @endforeach
                         
                         </li>
                       
                        
                        @endforeach
                     </ol>

                </td>
            </tr>

        @endforeach
    </table>

Here is my controller:

  public function filter(Request $request)
    {

        $events = Event::where([
            ['id', '!=', Null],
            [function ($query) use ($request) {
                // if (($search = $request->search)){
                //     $query->orWhere('event_parts' , 'LIKE', '%' . $search . '%') ->get();
                // }

                if (($search = $request->search AND $searchdate1 = $request->DateFilter1 AND $searchdate2 = $request->DateFilter2)) {
                    $query->orWhere('event_parts' , 'LIKE', '%' . $search . '%');
                    $query->whereBetween('event_start',[$searchdate1,$searchdate2]) ->get();

                }
                if (($searchdate1 = $request->DateFilter1 AND $searchdate2 = $request->DateFilter2)) {
                    $query->whereBetween('event_start',[$searchdate1,$searchdate2]) ->get();

                }
                if (($searchdate1 = $request->DateFilter1)) {
                    $query->whereBetween('event_start',[$searchdate1,now()]) ->get();
                }

            }]

        ])
           ->paginate(1000);
        $events = Event::paginate(5);

        $officers = User::all();

        // return view('events.filter', compact('events' , 'officers', 'officers2'))
        //     ->with('i', (request()->input('page', 1) - 1) * 10);
        return view('events.filter', compact('officers'));
    }

    public function print(Request $request)
    {

        $events = Event::where([
            ['id', '!=', Null],
            [function ($query) use ($request) {
      
                if (($search = $request->search AND $searchdate1 = $request->DateFilter1 AND $searchdate2 = $request->DateFilter2)) {
                    $query->orWhere('event_parts' , 'LIKE', '%' . $search . '%');
                    $query->whereBetween('event_start',[$searchdate1,$searchdate2]) ->get();

                }
                if (($searchdate1 = $request->DateFilter1 AND $searchdate2 = $request->DateFilter2)) {
                    $query->whereBetween('event_start',[$searchdate1,$searchdate2]) ->get();

                }
                if (($searchdate1 = $request->DateFilter1)) {
                    $query->whereBetween('event_start',[$searchdate1,now()]) ->get();
                }

            }]

        ])
            ->paginate(1000);


            $events = Event::all();
            $users = User::all();
        
            $event_id = DB::table('events')->pluck('id');
            $event_details = Event_Details::all();
            
            // $event_details = Event::with('event_venue')->where('id', $event_id)->get();
      
    
            $event_participants = DB::table('event_participants')
            ->join('events' ,'event_participants.user_id', '=','events.id')
       
            ->get();
    
        
           
        return view('events.print', compact('events', 'users', 'event_participants', 'event_details'))
            ->with('i', (request()->input('page', 1) - 1) * 10);

    }
}

Model Events:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Event extends Model
{
    protected $fillable = [
        'event_name',
        'event_category',
        'event_start_date',
        'event_end_date',
    ];

    public function users()
    {
        return $this->belongsTo('App\User');
    }

    public function participants()
    {
        return $this->hasMany('App\Event_Participants', 'event_id');
    }

 
    public function details()
    {
        return $this->hasOne('App\Event_Details', 'event_id');
    }
}

Model Event_Participants:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Event_Participants extends Model
{
    
    protected $table = 'event_participants';

    protected $fillable = 
    [
        'event_id',
        'user_id',
    ];

    
    public function events()
    {
        return $this->belongsTo('App\Event');
    }
}

Model Event_Details:

   <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    
    class Event_Details extends Model
    {
    
        protected $table = 'event_details';
    
        protected $fillable = [
        'event_id',
        'event_venue',
        'event_desc',
        'event_rem',
        'event_start_time',
        'event_end_time',
        'event_adder',
        ];
    
        public function events()
        {
            return $this->belongsTo('App\Event' ,'event_id');
        }
    }


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

preg_match() expects parameter 2 to be string, object given

i got this error when i'm trying to send multiple email, and i also want to pass a data to mail view.

here is my controller:

$get_no_inven = Permohonan::find($id_per)->no_inventaris;
    $get_users = DB::table('users')->where('hak_akses','=','deputi')->get(['email']);
    
    $recipients = [ $get_users ];

    $subject = 'Testing email no 2';
    $meta = 'meta';

    foreach($recipients as $recipient) {
        // here you declare variables accesable in view file
        $dataToPassToEmailView = [];
        // **key** of this table is variable **name in view**
        $dataToPassToEmailView['no_inventaris'] = $get_no_inven;

        Mail::send('mailkedua', $dataToPassToEmailView, function($message) use ($subject, $recipient, $meta) {
            $message->to($recipient, 'Deputi Manager')->subject($subject);
            $message->from('app.staging@nutrifood.co.id','Kalibrasi Online');
        });
    }

and here is my mail view:

<p>Dear Deputi Manager,</p>

<p>Berikut kami informasikan terdapat hasil kalibrasi terbaru alat dengan nomor inventaris 
Mohon bantuannya untuk melakukan approval, silahkan akses "Link CALON" <a href="http://baf-staging-x2:3030/lihat_permohonan_deputi/">http://baf-staging-x2:3030/lihat_permohonan_deputi/</a></p>


<p>Terima kasih,</p>
<p>CALON</p>

i don't understand where i'm doing wrong so please help me, thankyou!



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

How to send notification with image to IOS and android in PHP

I have a Laravel app in which I use some code to send FCM to send notification to IOS and Android, but now I need to include and image in the notification. the code I am using now is as below

$fcmUrl =   'https://fcm.googleapis.com/fcm/send';
        $notification = [
            'body' => 'Message',
            'title'=>'title',
            'sound' => true,
            'priority' => "high",
            'vibration'=>true,
            'sound'=> "Enabled",
            'badge'=>4,
            'id'=>2
            ];

        $extraNotificationData = ['one'=>1,'two'=>2];
      
        $fcmNotification = [
            //'registration_ids' => json_encode($token,JSON_FORCE_OBJECT), //multple token array
            'to' => $this->token, //single token
            'data' => $extraNotificationData,
            'notification' => $notification
        ];

        $headers = [
            'Authorization: key=Server_key',
            'Content-Type: application/json'
        ];

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $fcmUrl);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
        $result = curl_exec($ch);
        curl_close($ch); 


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

mercredi 13 janvier 2021

Why My Laravel 6 CMS not generating Sitemap of URL

I have laravel 6 CMS but its not generating sitemap for my site .So please help me to give required files for that .this cms have two directoris 1 root folder and second is out from root folder.

enter image description here

enter image description here

So if there is any expert in laravel 6 Please provide me sitemap generator files..with a little bit instrustions.Sitemap should include all urls of my site with 1.0 periority . and basic pages should be with low periority e.g contact us,about us,privacy policy etc.Thanks



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