mstdmstd

mstdmstd

Member Since 3 Years Ago

Experience Points
17,450
Total
Experience

2,550 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 4
17,450 XP
Aug
15
16 hours ago
Activity icon

Replied to Who To Connect In Filezilla With Provided Ftp Credentials ?

Sorry, if my questions silly. I remember this feature, my questions is how to keep listing of files I modified : When working for a long time I do not want to keep listing of modified files what I can check in git with

git status 

command

Activity icon

Replied to Who To Connect In Filezilla With Provided Ftp Credentials ?

I mean I need similar functionality like with git :

git status 

?

Activity icon

Replied to Who To Connect In Filezilla With Provided Ftp Credentials ?

program. And very inconvenient. A question at once : how to track modified files, what I did with

git status 

command?

Activity icon

Replied to Who To Connect In Filezilla With Provided Ftp Credentials ?

Thanks! But are there something better of filezilla(for kubuntu 18). Last years I worked with git and now filezilla seems very slow...

Activity icon

Replied to Who To Connect In Filezilla With Provided Ftp Credentials ?

I tried : https://prnt.sc/u00nlb But got error:

Error:	Disconnected: No supported authentication methods available (server sent: publickey)
Error:	Could not connect to server

I do not have any ssh keys...

Activity icon

Started a new Conversation Who To Connect In Filezilla With Provided Ftp Credentials ?

Hello,

From my client I received ftp account and sample listing, that credentials are valid:

[email protected]_IP:~$ ftp CLIENT.REMOTE.SERVER
Connected to CLIENT.REMOTE.SERVER.
220 ProFTPD Server (ProFTPD) [CLIENT.SERVER.IP]
Name (CLIENT.REMOTE.SERVER:ubuntu): SERVERUSER
331 Password required for SERVERUSER
Password:
230 User SERVERUSER logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful
150 Opening BINARY mode data connection for file list
-rwxrwxrwx 1 SERVERUSER psacln 692 Mar 9 21:29 Dockerfile-composer
-rwxrwxrwx 1 SERVERUSER psacln 508 Mar 9 21:29 Dockerfile-nginx

I have not worked with ftp last several years and maybe I forgot something, but I opened filezilla and tried to connect with provided credentials and got error :

I got error :

Status:	Connecting to CLIENT.SERVER.IP:22...
Status:	Connection established, waiting for welcome message...
Response:	SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
Error:	Cannot establish FTP connection to an SFTP server. Please select proper protocol.
Error:	Critical error: Could not connect to server

I entered parameters : https://prnt.sc/u005uz

Are some of them wrong ? Which valid?

Thanks!

Aug
14
1 day ago
Activity icon

Started a new Conversation Why In Livewire Register Form Prior Button Is Not Triggered?

Hi, with livewire / alpinejs I make register form as wizard, with Next/Prior buttons. Problem is that Prior button is not triggered I my component app/Http/Livewire/Register.php I have :

    <?php
    
    namespace App\Http\Livewire;
    
    use Facade\Ignition\SolutionProviders\IncorrectValetDbCredentialsSolutionProvider;
    use Livewire\Component;
    use App\User;
    use Auth;
    use DB;
    use App\Config;
    use Mockery\Generator\Method;
    
    class Register extends Component
    {
        public $current_step= 1;
    
        public $form= [
            'username'=>'User',
            'email'=>'[email protected]',
            'password'=> '123456',
            'password_confirm'=> '123456',
            'status'=> '',
            'account_type'=> '',
            'first_name'=> '',
            'last_name'=> '',
            'phone'=> '',
            'website'=> '',
            'notes'=> '',
            'avatar'=> '',
    
        ];
    
        public function nextStep()
        {
            $registerRules= User::getUserValidationRulesArray('register_step_' . $this->current_step);
    
            $this->validate($registerRules);
            $this->current_step++;
            if($this->current_step == 5) { // last Preview step submitted - can create user
                ...
            } //if($this->current_step == 5) { // last Preview step submitted - can create user
    
        } // public function nextStep()
    
    
        public function priorStep()
        {
            \Log::info( '-1 priorStep $this->current_step ::' . print_r(  $this->current_step, true  ) );
            $this->current_step--;
        }
    
        public function render()
        {
            return view('livewire.auth.register');
        }
    }

and template resources/views/livewire/auth/register.blade.php:

    <article class="page_content_container">
    
    @inject('viewFuncs', 'App\library\viewFuncs')
    
    
    @include('livewire.common.alert_messages')
    
    <form class="form-register" wire:submit.prevent="nextStep">
        <div class="card">
            <div class="card-body card-block">
                
                <h3 class="card-header">
                    {!! $viewFuncs->showAppIcon('register') !!}
                    <div class="spinner-border" role="status" wire:loading>
                        <span class="sr-only">Loading...</span>
                    </div>
                    {{ $current_step }}Register
                </h3>
                
                @if($current_step === 1)
                    <h4 class="card-subtitle">Fill your username and Email. Both must be unique</h4>
                    <dl class="block_2columns_md m-3"> <!-- username FIELD DEFINITION -->
                        <dt class="key_values_rows_label_13">
                            <label class="col-form-label" for="username">Username:<span class="required"> * </span></label>
                        </dt>
                        <dd class="key_values_rows_value_13">
                            <div class="input-group">
                                <div class="input-group-addon">
                                    {!! $viewFuncs->showAppIcon('user') !!}
                                </div>
                                <input
                                    wire:model.lazy="form.username"
                                    id="username"
                                    class="form-control editable_field"
                                    placeholder="Your username"
                                    autocomplete=off
                                >
                            </div>
                            @error('form.username')
                            <div class="validation_error">{{ clearValidationError($message,['form.'=>'']) }}</div> @enderror
                        </dd>
                    </dl> <!-- <dt class="block_2columns_md m-0"> username FIELD DEFINITION -->
                    
                    
                    <dl class="block_2columns_md m-3"> <!-- email FIELD DEFINITION -->
                        <dt class="key_values_rows_label_13">
                            <label class="col-form-label" for="email">Email:<span class="required"> * </span></label>
                        </dt>
                        <dd class="key_values_rows_value_13">
                            <div class="input-group">
                                <div class="input-group-addon">
                                    {!! $viewFuncs->showAppIcon('email') !!}
                                </div>
                                <input
                                    wire:model.lazy="form.email"
                                    id="email"
                                    class="form-control editable_field"
                                    placeholder="Your email address"
                                    autocomplete=off
                                >
                            </div>
                            @error('form.email')
                            <div class="validation_error">{{ clearValidationError($message,['form.'=>'']) }}</div> @enderror
                        </dd>
                    </dl> <!-- <dt class="block_2columns_md m-0"> email FIELD DEFINITION -->
                @endif
                
                @if($current_step === 2)
                    <h4 class="card-subtitle">Fill your password. It must be strong enough</h4>
                    <dl class="block_2columns_md m-3"> <!-- password FIELD DEFINITION -->
                        <dt class="key_values_rows_label_13">
                            <label class="col-form-label" for="password">Password:<span class="required"> * </span></label>
                        </dt>
                        <dd class="key_values_rows_value_13">
                            <div class="input-group">
                                <div class="input-group-addon">
                                    {!! $viewFuncs->showAppIcon('password') !!}
                                </div>
                                <input type="password"
                                       wire:model.lazy="form.password"
                                       id="password"
                                       class="form-control editable_field"
                                       placeholder="Your password"
                                       autocomplete=off
                                >
                            </div>
                            @error('form.password')
                            <div class="validation_error">{{ clearValidationError($message,['form.'=>'']) }}</div> @enderror
                        </dd>
                    </dl> <!-- <dl class="block_2columns_md m-0"> password FIELD DEFINITION -->
                    
                    
                    <dl class="block_2columns_md m-3"> <!-- password_confirm FIELD DEFINITION -->
                        <dt class="key_values_rows_label_13">
                            <label class="col-form-label" for="password_confirm">Password confirm:<span class="required"> * </span></label>
                        </dt>
                        <dd class="key_values_rows_value_13">
                            <div class="input-group">
                                <div class="input-group-addon">
                                    {!! $viewFuncs->showAppIcon('password') !!}
                                </div>
                                <input type="password"
                                       wire:model.lazy="form.password_confirm"
                                       id="password_confirm"
                                       class="form-control editable_field"
                                       placeholder="Your password confirm(must be equal password)"
                                       autocomplete=off
                                >
                            </div>
                            @error('form.password_confirm')
                            <div class="validation_error">{{ clearValidationError($message,['form.'=>'']) }}</div> @enderror
                        </dd>
                    </dl> <!-- <dl class="block_2columns_md m-0"> password_confirm FIELD DEFINITION -->
                @endif  {{--     @if($current_step === 2)--}}
                
                @if($current_step === 3)
                    ...
                @endif {{--  @if($current_step === 3)--}}
                
            
            </div> <!-- <div class="card-body card-block"> -->
            
            <section class="card-footer row_content_right_aligned">
                <button type="reset" class="btn btn-secondary btn-sm m-2 action_link">
                    {!! $viewFuncs->showAppIcon('cancel', 'white') !!}Cancel
                </button>
                
                @if($current_step > 1)
                    <button wire:click.prevent="priorStep" class="btn btn-secondary btn-sm m-2 ml-4 mr-4 action_link" type="button">
                        {!! $viewFuncs->showAppIcon('back', 'white') !!}Prior
                    </button>
                @endif
                <button type="submit" class="btn btn-primary btn-sm m-2 ml-4 mr-4 action_link">
                    {!! $viewFuncs->showAppIcon('next', 'white') !!}Next
                </button>
            </section>
        
        </div> <!-- <div class="card"> -->
    
    </form>
    </article> <!-- page_content_container -->
    
    
    @push('styles')
        <link href="/css/quill.snow.css" rel="stylesheet">
    @endpush
    
    @push('scripts')
        <script src="{{ asset('/js/quill.js') }}"></script>
    @endpush
    
    @section('scripts')
        <script>
            $("#username").focus();
        </script>
    @endsection

with priorStep method calling...

Method:: priorStep( of the component is not triggered, I do not see Log lines or events in the console and can not understand why?

Thanks!

Aug
12
3 days ago
Activity icon

Replied to I Search For User Idle Plugin/decision For Livewire / Alpine App

Yes, it looks like what I need, but how to use it? I added code in resources/js/app.js :

window.$ = window.jQuery = require('jquery');
require('./bootstrap');
window.toastr = require('toastr');

import { Idle } from 'idlejs';

// with predefined events on `document`
const idle = new Idle()
    .whenNotInteractive()
    .within(1) // I suppose that in 1 minute logoutUser() function will be triggered!
    .do(() => logoutUser())  // But not logoutUser - is not triggered
    .start();


var Turbolinks = require("turbolinks")
Turbolinks.start()

function logoutUser() {
    alert( 'logoutUser::' )
}

Which way is valid ?

Aug
11
4 days ago
Activity icon

Started a new Conversation I Search For User Idle Plugin/decision For Livewire / Alpine App

Are there something like https://github.com/soixantecircuits/idle-vue ( detects when the user hasn't interacted with your app for a while) compatible with laravel 7 /livewire 1.3 / turbolinks:5 / [email protected] ?

Thanks!

Aug
09
6 days ago
Activity icon

Replied to I Got Memory Lack Error In Docker Installing Laravel Plugin

In __DOCKER/web/Dockerfile.yml :

FROM php:7.3-apache
Activity icon

Started a new Conversation I Got Memory Lack Error In Docker Installing Laravel Plugin

Hello, Trying to add new package in laravel 7 under docker I got memory lack error :

# composer require nunomaduro/phpinsights --dev
Using version ^1.14 for nunomaduro/phpinsights
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

But in the console I see a lot of memory allowed:

[email protected]:/var/www/hostels3_docker_root# free
              total        used        free      shared  buff/cache   available
Mem:        8085252     5778240     1520788       86808      786224     1956736
Swap:       2104476     2026072       78404

In the php info I see :

memory_limit	2048M	128M

In __DOCKER/web/virtualhost.conf I have parameter :

	php_value  memory_limit  2048M

and

Configuration File (php.ini) Path	/usr/local/etc/php

but trying to open php.ini with command :

nano /usr/local/etc/php.ini

nothing was found. Seems this file is virtual ?

Also I know that (when using lamp) for console commands php cli must be configured. I tried to install php7.3-cli in my __DOCKER/web/Dockerfile.yml :

 RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

  RUN  docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif php7.3-cli \
&& a2enmod rewrite

COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf

But I got error that php7.3-cli is not found.

In which way can I fix memory lack I have ?

In my hosting kubuntu 18 I have 8GiB of memory :

$ lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.4 LTS
4.15.0-112-generic
x86_64
$ free
              total        used        free      shared  buff/cache   available
Mem:        8085252     5623840      141952      110116     2319460     2073288
Swap:       2104476      302848     1801628

Thanks!

Aug
06
1 week ago
Activity icon

Replied to I Got Error Using Datepicker In Livewire App

Thanks! My date format is “Thu Aug 06 2020”, I want to change it and for this I modify file resources/views/components/date-picker.blade.php :


<div>
    <input
        x-data
        x-ref="input"
        x-init="new Pikaday({ field: $refs.input, format:'D MMM YY' })"
        type="text"
        {{ $attributes }}
    >
</div>

But date format is the same... Which way is valid ?

Aug
05
1 week ago
Activity icon

Started a new Conversation I Got Error Using Datepicker In Livewire App

Hello, In laravel 7 with livewire 1.3 I want to add datepicker from https://laravel-livewire.com/docs/alpine-js ("Creating A DatePicker Component" docs) But I get error :

Unable to locate a class or view for component [date-picker]. 
(View: /mnt/_work_sdb8/wwwroot/lar/hostels3/resources/views/livewire/hostel/hostel-view-page.blade.php)

and in my blade file I use <x:date-picker in modal dialog, which I open with alpinejs:

<div class="card item_container">
    
    ...
    
    <div
        class="modal_editor_title card-title"
    >
        <h4 class="modal-title p-2">
            <button class="close" type="button" x-on:click="show_booking_enquiry_modal= false">
                <span aria-hidden="true">&times;</span>
            </button>
        </h4>
    </div> <!-- modal_editor_title -->
    
    <div class="modal_editor_fields card-body" :style="'max-height: ' + ( modalHeight() - 20 ) +'px; overflow-y: scroll;'">
        
        <form class="form-login" wire:submit.prevent="newBookingEnquirySubmit">
            <div class="card">
                <div class="card-body card-block">
                    
                    <h4 class="card-subtitle">Fill your enquery</h4>
                    
                    
                    <dl class="block_2columns_md m-3"> <!-- start_date FIELD DEFINITION -->
                        <dt class="key_values_rows_label_13">
                            <label class="col-form-label" for="start_date">Start date:</label>
                        </dt>
                        <dd class="key_values_rows_value_13">
                            <label for="start_date">Start Date</label>
                            
                            <x:date-picker wire:model="start_date" id="start_date"/>
                            
                            
                            @error('hostelEnqueryForm.start_date')
                            <div class="validation_error">{{ $message }}</div> @enderror
                        </dd>
                    </dl> <!-- <dt class="block_2columns_md m-0"> start_date FIELD DEFINITION -->
                    
                    ...
                
                
                </div> <!-- <div class="card"> -->
            </div> <!-- <div class="card"> -->
        
        </form>
    
    </div>  <!-- modal_editor_fields-->
    
    ...
    
    <div class="modal_editor_footer card-footer row_content_right_aligned">
        <div class="m-2">
            <button wire:click="submitBookingEnquery()" class="btn btn-primary editor_button_submit ml-5" type="button">
                {!! $viewFuncs->showAppIcon('save', 'white') !!} Submit
            </button>
            <button x-on:click="show_booking_enquiry_modal= false" class="btn btn-cancel-action" type="button">
                {!! $viewFuncs->showAppIcon('cancel', 'white') !!} Cancel
            </button>

In layout file In my resources/views/layouts/app.blade.php I have : I add Pikaday .js and .css files:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>Laravel:Livewire</title>
    
    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
    
    <!-- Styles -->
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/pikaday/css/pikaday.css">
    <link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css">
    <link rel="icon" type="image/png" href="/favicon.ico"/>
    
    <link href="/css/app.css" rel="stylesheet">
    
    
    @livewireStyles
    
    
    <script src="{{ asset('/js/app.js') }}"></script>
    <script src="{{ asset('js/lazyload.js') }}"></script>
    
    <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>
    
    @livewireScripts
    @stack('scripts')
    
    
    <script src="{{ asset('/js/app/app_funcs.js') }}"></script>

</head>

As I see installation rules in https://github.com/Pikaday/Pikaday . What did I miss ? Can it be order of refs in app.blade.php file ?

Thanks!

Aug
04
1 week ago
Activity icon

Started a new Conversation I Search WYSIWYG Ediitor Livewire/alpine

Hello, Can you advice some modern WYSIWYG ediitor compatible with laravel 7 /livewire 1.3 / turbolinks:5.2 / [email protected] / bootstrap 4.5

and link to installation guide. Thanks!

Aug
01
2 weeks ago
Activity icon

Replied to Upgrade Php To 7.3 I See 7.2 In My Browser

But I got error :

# sudo a2dismod php7.2
Module php7.2 disabled.
To activate the new configuration, you need to run:
  systemctl restart apache2
[email protected]:/mnt/_work_sdb8/wwwroot/lar/hostels3# sudo a2enmod php7.3
ERROR: Module php7.3 does not exist!

?

Activity icon

Started a new Conversation Upgrade Php To 7.3 I See 7.2 In My Browser

Hello, Looking at this https://www.cloudbooklet.com/how-to-install-php-7-3-on-ubuntu-18-04/ article I try to upgrade php to 7.3 on my local Ubuntu 18

But after I run command:

sudo apt install php7.3
restyarting the OS I see in the console : 
$ php -v
PHP 7.3.20-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jul  9 2020 16:34:09) ( NTS )

But phpinfo in the browser shows me PHP Version 7.2 :

PHP Version 7.2.24-0ubuntu0.18.04.6
System	Linux athoe 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 9 23:41:39 UTC 2020 x86_64
Build Date	May 26 2020 13:09:11
Server API	Apache 2.0 Handler
Virtual Directory Support	disabled
Configuration File (php.ini) Path	/etc/php/7.2/apache2
Loaded Configuration File	/etc/php/7.2/apache2/php.ini
Scan this dir for additional .ini files	/etc/php/7.2/apache2/conf.d

also I failed to open file : 
sudo nano /etc/php/7.3/apache2/php.ini
as directory /etc/php/7.3/apache2 was not found
and checking the system I see : 

[email protected]:/etc/php# ls -la
total 24
drwxr-xr-x   4 root root  4096 �����  1 17:33 .
drwxr-xr-x 156 root root 12288 �����  1 17:33 ..
drwxr-xr-x   5 root root  4096 �����  5  2019 7.2
drwxr-xr-x   5 root root  4096 �����  1 17:33 7.3
[email protected]:/etc/php# cd 7.2
[email protected]:/etc/php/7.2# ls -la
total 20
drwxr-xr-x 5 root root 4096  5  2019 .
drwxr-xr-x 4 root root 4096   1 17:33 ..
drwxr-xr-x 3 root root 4096  4 18:22 apache2
drwxr-xr-x 3 root root 4096   3 10:01 cli
drwxr-xr-x 2 root root 409613  2020 mods-available
[email protected]:/etc/php/7.2# cd ../
[email protected]:/etc/php# cd 7.3
[email protected]:/etc/php/7.3# ls -la
total 20
drwxr-xr-x 5 root root 4096  1 17:33 .
drwxr-xr-x 4 root root 4096  1 17:33 ..
drwxr-xr-x 3 root root 4096  1 17:33 cli
drwxr-xr-x 4 root root 4096  1 17:33 fpm
drwxr-xr-x 2 root root 4096  1 17:33 mods-available

What did I miss in my setup ?

Thanks!

Jul
26
2 weeks ago
Activity icon

Started a new Conversation Why Emitted Event Of Livewire Is Not Triggered?

Hello, In laravel 7 learning livewire/livewire 1.3 I encountered that emitted events are not always triggered

I created component with command

php artisan make:livewire hostel/hostelsHomepageSpotlight

and simplifying the code I do not see alert of event. In app/Http/Livewire/Hostel/HostelsHomepageSpotlight.php :

<?php

namespace App\Http\Livewire\Hostel;

use Auth;
use DB;
use App\Config;

use App\Hostel;
use App\HostelImage;
use App\library\CheckValueType;
use App\Settings;
use Livewire\Component;

class HostelsHomepageSpotlight extends Component
{

    public function render()
    {

        $hostels     = [];
        $current_page= 1;
        $hostel_rows_count = Hostel
            ::getByStatus('A')
            ->count();

        $this->emit('hostelsHomepageSpotlightOpened', [ 'mode'=> 'hostels_homepage_spotlight', 'current_page'=>$current_page, 'hostel_rows_count'=>$hostel_rows_count ] ); // EMIT EVENT

        return view('livewire.hostel.hostels-homepage-spotlight', [
            'hostelsDataRows' => $hostels,
            'hostel_rows_count'=> $hostel_rows_count,
            'current_page'=> $current_page,
        ]);
    }


}

and in resources/views/livewire/hostel/hostels-homepage-spotlight.blade.php:

<div>
    
    <h1>hostelsHomepageSpotlightOpened</h1>

</div>   

<script>
    // If to uncomment line below I see  alert
    // alert( 'resources/views/livewire/hostel/hostels-homepage-spotlight.blade.php::' )
    window.livewire.on('hostelsHomepageSpotlightOpened', data => {
        // I DO NOT SEE ALERT BELOW ANYWAY
        alert( 'hostelsHomepageSpotlightOpened::' )
        console.log('facility_opened data::')
        console.log(data)
        // alertsInit(data.mode)
        // lazyImagesInit("img.lazy_image")
    })
</script>

Why event is not triggered ? Is there is a way to debug it ?

Thanks!

Jul
22
3 weeks ago
Activity icon

Started a new Conversation How To Set All Past Dates At The End Of Resulting Data?

Hello, In laravel 5.7 app I have data from server ordered by boolean field(invoices.was_invoice_sent) and datetime field(invoices.billed_through_date)

        $invoicesCollection = Invoice
            ::orderBy('invoices.was_invoice_sent', 'asc')
            ->orderBy('invoices.billed_through_date', 'asc')

and on client side I set property not to sort on client side:

    oTable = $('#get-invoice-dt-listing-table').DataTable({
        processing: true,
        serverSide: true,
        "ordering": false,
        "lengthChange": true,

My question is if there is a way to set all past dates by invoices.billed_through_date(less today) at the end of resulting data?

Thanks!

Jul
13
1 month ago
Activity icon

Started a new Conversation Search Tool To Generate Blade/bootstrap Code Into Pdf

Hello, I need some tool to generate my blade/bootstrap 4.1 code(laravel 5) into pdf with support of flexbox and css class definitions

I tried spipu/html2pdf 5.2, but I did not find how it supports css class definitions... Can you advice some? With link to flexbox and css class definitions. Also I need a feature if resulting page has more 1 page to define header and footer on any page.

Thanks!

Jul
12
1 month ago
Activity icon

Started a new Conversation Can Not Set Font For Html2pdf In Laravel App

Hello, In laravel 5.7 app I work with spipu/html2pdf 5.2 to generate piece of html/bootstrap code into pdf file and I have a problem with font definition

My pages use Roboto font, but if I make :

    $html2pdf = new HTML2PDF('P','A4','en', true, 'UTF-8');
      $html2pdf->addFont('Roboto', '', public_path('/fonts/roboto/Roboto_regular.ttf'));  
      //I have font in my app /fonts/roboto/Roboto_regular.ttf
      // and I can preview it : https://prnt.sc/tgcgjq
      
      $html2pdf->WriteHTML(htmlspecialchars_decode($pdf_content));
      $html2pdf->Output($save_to_file,'F');

But I got error :

TCPDF ERROR: The font definition file has a bad format: /mnt/_work_sdb8/wwwroot/lar/the-box-booking/public/fonts/roboto/Roboto_regular.ttf

The difference in path is that I use links :

  -s   /mnt/_work_sdb8/wwwroot  /_wwwroot

If I try to use times font(which I want to use for generated pdf file) as

$html2pdf->addFont('times'); 

I got error :

TCPDF ERROR: Could not include font definition file: &#039

looks like in last case fontname is not set , but I do not know how have I to set it ? I have times set in my OS, I suppose I do not to put it under /public/fonts/?

Thanks!

Jul
06
1 month ago
Activity icon

Started a new Conversation How To Make Recursive Calling Of Subitems In Vuejs2?

Hello, In my laravel/blade app when I need to show comments of a product with parent_id I wrote a function with recursive calling of itself, like

    public function showCommentItem( $commentsList, $parent_id, $product_id, $deeps, $backend_home_url, $images_dir, $current_template )
    {
        $ret_html= '';
        $ret_html.= '<ul class="p-b-30">';
        foreach( $commentsList as $nextComment ) { // run list of comments
            if ( (int)$nextComment->parent_product_comment_id == (int)$parent_id ) {
                $approved_status_html= '';
                $ban_user_html= '';
                $rating_html= '';
                $status_html= '<span class="'.($nextComment->approved_status=='N'?'text-danger':'').'">'.$viewFuncs->getProductCommentApprovedStatusLabel( $nextComment->approved_status ).'</span>';
                $current_status_html= '.&nbsp;<span class="_tree_current_status ">Current Status</span>&nbsp;<b>'. $status_html . '</b>.&nbsp;';
                if ( $nextComment->approved_status == "N" or $nextComment->approved_status == "A" ) { // .text-center
                   ...
                }

                   ...
                
                $ret_html.= '<li class="'.($nextComment->subitems_count > 0 ? ' isFolder isExpanded ' : '').' p-b-10" >'.
                    '<small>'./*$nextComment->user_id .'  '.$nextComment->user_active_status .'  : '.*/$nextComment->username.$ban_user_html.'</small>'./*'<br>' . */
                    '<small>'.$current_status_html . $approved_status_html .
                    '<span class="time pull-right">'.$nextComment->created_at.''.$rating_html.'</span>'.'</small>' . '<br>' ;
                   ...
                if ( $nextComment->subitems_count > 0 ) {
                    $deeps++;
                    $ret_html.= $this->showCommentItem( $commentsList, $nextComment->id, $product_id, $deeps, $backend_home_url, $images_dir, $current_template);
                }
                $ret_html.= '</li>';
            } //                 if ( $nextComment->parent_product_comment_id == $parent_id ) {

        } //             recursiveforeach( $commentsList as $nextComment ) { // run list of comments
        $ret_html.= '</ul>';

        return $ret_html;

whrere $commentsList - my comments, $parent_id - is 0 at root calling, $product_id - common for all comments and I got string for all comments with all functionality.

I try to make similar in bootstrap-vue project, like :

            <b-list-group>
                  // I got root items only with getAdCommentsByParentId method 
                <b-list-group-item v-for="(nextAdComment) in getAdCommentsByParentId(0)" :key="nextAdComment.id" class="m-1 p-0">
    
                    <div class="pre-formatted" v-html="nextAdComment.id+' ( '+nextAdComment.parent_ad_comment_id+') : '+concatStr(nextAdComment.text,50)"></div>
                </b-list-group-item>
    
            </b-list-group>
      ...
      
      
              methods: {
                getAdCommentsByParentId: function (parent_ad_comment_id) {
    
                    var retArray= []
                    if(!this.adComments) return []
                    this.adComments.map((nextAdComment) => {
                        if (nextAdComment.parent_ad_comment_id == parent_ad_comment_id) {
                            retArray[retArray.length]= nextAdComment
                        }
                    })
                    return retArray
                },

But I do not know how to make recursive calling like I did with blade?

    "bootstrap-vue": "^2.3.0",
    "vue": "^2.6.11",

Thanks!

Jun
28
1 month ago
Activity icon

Replied to How To Catch Custom Events From Laravel In Vuejs App

If you have expierence with similar what I need please share it. Hope I clearly explained what I need.

Jun
25
1 month ago
Activity icon

Replied to I Got Composer Memory Lack Error On My Ubuntu 16

My current options : 1 GB Memory / 25 GB Disk / SFO2 - Ubuntu 16.04.4 x64 ipv6: Enable now Private IP: No VPC Network Floating IP: Enable now

How do you think about these new options : https://prnt.sc/t666yq Will it be enough ? Will I overpay?

Also a question if there a way to return back to my original size ?

Jun
24
1 month ago
Activity icon

Replied to I Got Composer Memory Lack Error On My Ubuntu 16

Thanks for the link! Added in /etc/fstab:

/swapfile none swap defaults 0 0

I found and modified php.ini

# php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini
[email protected]:/var/www/html/the-box-booking# sudo nano /etc/php/7.2/cli/php.ini

with options:

memory_limit = -1
max_execution_time = 3300
max_input_time = 240
post_max_size = 400M

Also I run

composer clear-cache

php -r "echo ini_get('memory_limit').PHP_EOL;"

[email protected]:/var/www/html/the-box-booking# php -r "echo ini_get('memory_limit').PHP_EOL;"
-1

but rebooting the system to apply my changes I stopped services supposedly I do not need :

sudo service apache2 stop
  service mysql stop

and check memory 1 more time :

# free
              total        used        free      shared  buff/cache   available
Mem:        1015908       37652      559028        3136      419228      822304
Swap:       1048572           0     1048572

and running composer I again get the memory lack error :

 composer install
The "kylekatarnls/update-helper" plugin was skipped because it requires a Plugin API version ("^1.1.0 || ^2.0.0") that does not match your Composer installation ("1.0.0"). You may need to run composer update with the "--no-plugins" option.
Loading composer repositories with package information
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory
Killed
...

Are there something else I can try ?

Activity icon

Started a new Conversation I Got Composer Memory Lack Error On My Ubuntu 16

Hello, In my laravel 5 app I installed spatie/browsershot and after that got memory lack error on my ubuntu 16, under Digital Ocean

I rebooted OS and attached swap memory but memory lack error anyway:

# free
              total        used        free      shared  buff/cache   available
Mem:        1015908      175784      530992       25336      309132      662096
Swap:             0           0           0
[email protected]:~# sudo -s
[email protected]:~# sudo fallocate -l 1G /swapfile
[email protected]:~# sudo mkswap /swapfile
mkswap: /swapfile: warning: wiping old swap signature.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=76e8a9d1-2d9c-4a3b-a7af-cd152d03532c
[email protected]:~# sudo swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[email protected]:~# sudo swapon -a
[email protected]:~# free
              total        used        free      shared  buff/cache   available
Mem:        1015908      176972      528020       25336      310916      660980
Swap:       1048572           0     1048572
[email protected]:~# cd /var/www/html/the-box-booking
[email protected]:/var/www/html/the-box-booking# mc

[email protected]:/var/www/html/the-box-booking# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory
Killed
[email protected]:/var/www/html/the-box-booking# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 16.04.4 LTS
4.4.0-184-generic
x86_64

 php -v
PHP 7.2.15-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:37:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.15-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

I do not have a lot of packages in my composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

I suppose that I need to increase memory of my ubuntu instance ( Digital Ocean ). I have a cheapest instance options, as the app has not a lot of data/load. How many of memory do I need? How better to increase options of my ubuntu instance ? I do not like to overpay for the memory I really do not need.

Thanks!

Activity icon

Replied to I Got Symfony/translation Errors Installing Laravel 5 On Remote Server

Sorry, I did it by error. How can I delete this branch?

Activity icon

Started a new Conversation I Got Symfony/translation Errors Installing Laravel 5 On Remote Server

Hello, Uploading my laravel 5 app on ubuntu under Digital Ocean server I got error in the browser:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Googling for decision I found that the error could need symfony/translation installation and I tried to install it locally on my kubuntu 18 and got error :

$ composer require symfony/translation                                     
Using version ^5.1 for symfony/translation
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install symfony/translation v5.1.2
    - Conclusion: don't install symfony/translation v5.1.1
    - Conclusion: don't install symfony/translation v5.1.0
    - Conclusion: don't install symfony/translation v5.1.0-RC2
    - Conclusion: don't install symfony/translation v5.1.0-RC1
    - Conclusion: don't install symfony/translation v5.1.0-BETA1
    - Conclusion: don't install symfony/translation 5.2.x-dev
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - Installation request for symfony/translation ^5.1 -> satisfiable by symfony/translation[5.1.x-dev, 5.2.x-dev, v5.1.0, v5.1.0-BETA1, v5.1.0-RC1, v5.1.0-RC2, v5.1.1, v5.1.2].
    - Installation request for symfony/http-kernel (locked at v4.4.9) -> satisfiable by symfony/http-kernel[v4.4.9].

My local composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

How this can be salved ? Thanks!

Activity icon

Replied to I Got Symfony/translation Errors Installing Laravel 5 On Remote Server

I check on server and see :

# php -v
PHP 7.2.15-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:37:29) ( NTS )

as in composer.json I have :

 "require": {
        "php": "^7.1.3",
Activity icon

Started a new Conversation I Got Symfony/translation Errors Installing Laravel 5 On Remote Server

Hello, Uploading my laravel 5 app on ubuntu under Digital Ocean server I got error in the browser:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Googling for decision I found that the error could need symfony/translation installation and I tried to install it locally on my kubuntu 18 and got error "

$ composer require symfony/translation                                     
Using version ^5.1 for symfony/translation
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install symfony/translation v5.1.2
    - Conclusion: don't install symfony/translation v5.1.1
    - Conclusion: don't install symfony/translation v5.1.0
    - Conclusion: don't install symfony/translation v5.1.0-RC2
    - Conclusion: don't install symfony/translation v5.1.0-RC1
    - Conclusion: don't install symfony/translation v5.1.0-BETA1
    - Conclusion: don't install symfony/translation 5.2.x-dev
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - Installation request for symfony/translation ^5.1 -> satisfiable by symfony/translation[5.1.x-dev, 5.2.x-dev, v5.1.0, v5.1.0-BETA1, v5.1.0-RC1, v5.1.0-RC2, v5.1.1, v5.1.2].
    - Installation request for symfony/http-kernel (locked at v4.4.9) -> satisfiable by symfony/http-kernel[v4.4.9].

My local composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "spipu/html2pdf": "^5.2",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

How this can be salved ? Thanks!

Jun
16
1 month ago
Activity icon

Started a new Conversation How To Catch Custom Events From Laravel In Vuejs App

Hello, Making @vue/cli 4.0.5 app with data reading from Laravel 7 Backend REST API I need to make some notification from Admin part of the site and all the users who works in frontend part the app at this time must to see it.

I suppose that I need in laravel part to send request header( method with custom code and in frontend part to catch this event in src/App.vue, like :

        created() {
            let self = this

            Vue.http.interceptors.push(function (request, next) {
                next(function (response) {
                    if (response.status === 503) {
                        this.$router.push('/MaintenanceMessage')
                    }

                    if (response.status === MyCustomCode) {
                        this.$router.push('/MaintenanceMessage')
                    }
                    if (response.status == 401 || response.status == 403) {
                        // alert( '401 ERROR ::')

But I do not know which MyCustomCode can be used here, which are permitted? If this a valid way ? Are there some libs/plugins/scripts for this?

    "bootstrap-vue": "^2.3.0",
    "vue": "^2.6.11",
    "vue-resource": "^1.5.1",

Thanks!

Jun
14
2 months ago
Activity icon

Replied to I Got “The Provided Object Is Not A Layer” Error Trying To Parse Packled LayerGroups

I tried to replace CircularJSON with similar library https://github.com/moll/json-stringify-safe but tried to keep in this.layerGroups array newLayerGroup with code from sample

                    var stringify = require('json-stringify-safe');

                    this.layerGroups[this.layerGroups.length] = {
                        country: nextGroupedAdLocations.country,
                        layersObj: stringify(newLayerGroup, null, 2)
                    }

My app hang up deadly.

Are there some different possible decisions for my problem? I remind that I needed to use some LayerGroup stringify method, as I got

converting circular structure to json

error. Are there some different ways to fix this error?

Jun
13
2 months ago
Activity icon

Started a new Conversation I Got “The Provided Object Is Not A Layer” Error Trying To Parse Packled LayerGroups

Hello, In bootstrap-vue app I use leaflet 1.6.0 and I have dynamic listing of locations grouped by country and I keep all data in 1 array :

                    let newLayerGroup= this.leaflet.layerGroup(markersList)
                    console.log('!!!newLayerGroup::')
                    console.log(newLayerGroup)

                    var CircularJSON = require('circular-json')
                    this.layerGroups[this.layerGroups.length] = {
                        country: nextGroupedAdLocations.country,
                        layersObj: CircularJSON.stringify(newLayerGroup)
                    }

I have to use https://github.com/WebReflection/circular-json lib to fix error

converting circular structure to json

and when I save my data I see in the console of my browser: https://imgur.com/a/aragHq7 I see that all data of layerGroup are wrapped into NewClass and I have a problem with it when clicking on country link I try to filter and parse my data :

            filterByGroupedCountry(country_key, country_label) {
                this.layerGroups.forEach(nextLayerGroup => { // draw all layerGroups
                    if (nextLayerGroup.country === country_key) {
                        var CircularJSON = require('circular-json')
                        let layersObj = CircularJSON.parse(nextLayerGroup.layersObj)
                        console.log('!!!layersObj::')
                        console.log(layersObj)
                        if(this.locationsMap.hasLayer(layersObj)) {
                            this.locationsMap.removeLayer(layersObj);
                        } else {
                            this.locationsMap.addLayer(layersObj);
                        }

I got error :

[Vue warn]: Error in v-on handler: "Error: The provided object is not a Layer."

found in

---> <TestPage> at src/views/Test2.vue
       <AppContainer> at src/App.vue
         <Root>
warn @ vue.runtime.esm.js?2b0e:619
logError @ vue.runtime.esm.js?2b0e:1884
globalHandleError @ vue.runtime.esm.js?2b0e:1879
handleError @ vue.runtime.esm.js?2b0e:1839
invokeWithErrorHandling @ vue.runtime.esm.js?2b0e:1862
invoker @ vue.runtime.esm.js?2b0e:2179
original._wrapper @ vue.runtime.esm.js?2b0e:6917
vue.runtime.esm.js?2b0e:1888 Error: The provided object is not a Layer.
    at NewClass.addLayer (leaflet-src.js?e11e:6666)
    at eval (Test2.vue?c6a2:536)
    at Array.forEach (<anonymous>)
    at VueComponent.filterByGroupedCountry (Test2.vue?c6a2:519)
    at click (eval at ./node_modules/cache-loader/dist/cjs.js?

In the console I see that parsed data are not wrapped in NewClass : https://imgur.com/a/k0DAlOc

How to fix it ?

Thanks!

Jun
09
2 months ago
Activity icon

Started a new Conversation I Need Script For Selection With Images

Hello, in my laravel 5.7 / blade / jquery 3.4.1 app I need to make selection by click on image https://prnt.sc/susohe but clicking on this image I want to have selection Also I in this image need to show priorly selected item it is was selected

items like https://prnt.sc/suspnc That must be not modal dialog for all the page or just selection input.

Can you advice some pluging or script?

Thanks!

Jun
06
2 months ago
Activity icon

Replied to I Need Editor Withing One Listing

I have worked with this yajra/laravel-datatables-oracle lib before,

I think then I need to show editor in some table cell, I have to make :

        $datatablesCollection = Datatables
            ::of($storageSpacesCollection) /*  Set format/labels for specific columns  */

            ->editColumn('level', function ($storageSpace) {
               ... // and to draw selection input or money input field as string

but I am not sure how

  1. Can I add new row with all fields with default value?
  2. Can I delete existing row ?
  3. I can edit existing row
  4. But when I click on “Save” I need to track status of any row to generate Insert/Update/Delete statement? How can I do it with yajra/laravel-datatables-oracle ?

Are there some better tools for this ?

Activity icon

Started a new Conversation I Need Editor Withing One Listing

Hello, in my laravel 5.7 / blade / jquery 3.4.1 app I need editor withing one listing, like : https://prnt.sc/suvp5v with crud operations and 1 common Save bitton.

Can you advice some pluging or script?

Thanks!

Jun
04
2 months ago
Activity icon

Started a new Conversation How In Vuex Get Method To Call Action Method?

Hello, In @vue/cli 4.0.5 / vuex 3 app with data reading from Laravel Backend API I keep some parameters in database settings table and I want to read them once and to keep it in vuex storage. In my src/store/index.js I check if site_name value is empty I call retrieveSiteName action and got error :

 Error in render: "TypeError: Cannot read property 'dispatch' of undefined"
export default new Vuex.Store({
    state: {// store data
        status: '',
        token: localStorage.getItem('token') || '',
        user: null,
        site_name: '', // I need to read this value once
        ...
    }, // state: { // store data

    getters: {
        ...


        site_name(state) {
            if (state.site_name.length > 0) {
                return state.site_name
            }
            let site_name = localStorage.getItem('site_name')
            if (site_name != null ) {
                return site_name
            }
            // this.actions.retrieveSiteName(state)

            // state.this.dispatch('retrieveSiteName')
            this.dispatch('retrieveSiteName') // Error Here!
            
            return ''
        }, // site_name(state) {
        ...

    actions: { // async methods
        retrieveSiteName(context) {
            console.log('retrieveSiteName::')
            let apiUrl = process.env.VUE_APP_API_URL
            axios.post(apiUrl + '/app_settings', 'site_name')
                .then((response) => {
                    console.log('retrieveSiteName response::')
                    console.log(response)

                    context.commit('refreshSiteName', response.data.site_name)

                })
                .catch((error) => {
                    console.error(error)
                })
        }, // retrieveSiteName(context) {

Seems according to vuex there is no valid way of calling retrieveSiteName from get name method.

Can you advice some practical decision here? I described my situation : I do not like to read the same data from db(As I do now) any time when I move to other page. That is different case when user is logged and all his personal info is read from db and stored in vuex store. User can open any pages of site frontend(say from bookmark) and I need once is to read data from db and stored in vuex store...

Thanks!

May
31
2 months ago
Activity icon

Replied to How To Rewrite Access_token In Vuex Store Of The Frontend(vue) App?

In client part of my vuejs file I fave a request interceptors in src/App.vue:

        created() {
            let self = this
            this.$http.interceptors.response.use(undefined, function (error) {

                return new Promise(function (/*resolve, reject*/) {
                    if (typeof error.response.status !== 'undefined' && error.response.status === 401) {
                        self.$store.dispatch('logout')  // DEBUGGING
                        self.showPopupMessage('Access', 'Not authorized !', 'warn')
                        let splitted0 = self.getSplitted(error.response.config.url, '/login', 0)

                        if (splitted0 == '') { // not move from login page
                            self.$router.push('/login')   // DEBUGGING
                        }
                    }

                    if (typeof error.response.status !== 'undefined') {
                        if (error.response.status === 401) {
                            self.$store.dispatch('logout') // DEBUGGING
                            self.showPopupMessage('Access', 'Not authorized !', 'warn')
                            self.$router.push('/login')  // DEBUGGING
                        }
                    }

                    throw error
                })
            })


        }, //  created() {

I catch 401 error in it and wonder is it possible to catch the request from the server

                header('Authorization: Bearer ' . $refreshed);

and to write to new access_token value from $refreshed? But how can I catch it? But some special return request code?

May
30
2 months ago
Activity icon

Started a new Conversation How To Rewrite Access_token In Vuex Store Of The Frontend(vue) App?

Hello, In laravel 7 backend rest api app I use jwt-auth and setting in /config/jwt.php setting parameters

'ttl' => 20,  # 20 minutes
'refresh_ttl' => 20160, // 2 weeks

on login in frontend ( @vue/cli 4.0.5 / vuex ) I keep access_token in vuex store. Working in frontend after 20 minutes( ttl parameter ) I got 401 error and my app makes logout. I need to make logout in 20 minutes only in case the frontend app was idle. I found a decision with app/Http/Middleware/JwtMiddleware.php adding with code :

<?php

namespace App\Http\Middleware;

use Closure;
use Tymon\JWTAuth\Exceptions\JWTException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;

class JwtMiddleware extends BaseMiddleware
{
    public function handle($request, Closure $next)
    {
        try {
            if (! $user = $this->auth->parseToken()->authenticate()) {
                return response()->json(['success' => false, 'error' => __('Invalid User.')]);
            }
        } catch (TokenExpiredException $e) {
            try {
                $refreshed = $this->auth->refresh($this->auth->getToken());
                \Log::info( '-0 JwtMiddleware$e $refreshed ::' . print_r(  $refreshed, true  ) );
                $user = $this->auth->setToken($refreshed)->toUser();
                \Log::info( '-00 JwtMiddleware$e $user->id ::' . print_r(  ($user->id ?? 'User not defined'), true  ) );
                header('Authorization: Bearer ' . $refreshed);
            } catch (JWTException $e) {
                return response()->json(['success' => false, 'error' => __('Could not generate refresh token')]);
            }
        } catch (JWTException $e) {
            return response()->json(['success' => false, 'error' => __('Invalid request')]);
        }
        return  $next($request);
    }
}

I suppose that with line

                header('Authorization: Bearer ' . $refreshed);

new token is generated and returned to frontend app. But how to render on frontend part ? I think I need to rerwrite access_token in vuex store of the frontend app.

How can I do this ?

Thanks!

May
25
2 months ago
Activity icon

Replied to I Got 401 Error In Undelete Method Of Vue Request?

Trying yo debug this issue I use clone function for creating of credentials var, which I use in request.

        getClone: function (obj) {
            let copy = JSON.parse(JSON.stringify(obj))
            return copy
        },

also I added 2 varaibles to which authorization_1 and authorization_2 ro which I assign

                let credentials= this.getClone(this.credentialsConfig)
                credentials.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken
                this.authorization_1= credentials.headers.Authorization
                console.log('removeTask credentials::')
                console.log(credentials)
                axios.delete(this.apiUrl + '/adminarea/tasks/' + id, credentials).then((/*response*/) => {

and

                let credentials= this.getClone(this.credentialsConfig)
                credentials.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken
                this.authorization_2= credentials.headers.Authorization
                console.log('unremoveTask credentials::')
                console.log(credentials)
                axios.put(this.apiUrl + '/adminarea/tasks/' + id+"/unremove", credentials).then((/*response*/) => {

and outputing these authorization_1 and authorization_2 vars on the page I can compare their content and see that they have the same value like

‘Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWwtY3Rhc2tzLWFwaS5jb20vYXBpL2xvZ2luIiwiaWF0IjoxNTkwNDE3NzcxLCJleHAiOjE1OTA0MjEzNzEsIm5iZiI6MTU5MDQxNzc3MSwianRpIjoiSHRjQmNPbUQwbjhKVHlqbyIsInN1YiI6MSwicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlMGIwNDc1NDZhYSJ9.A3lZqX2hEaYGYuBoh9rDzjcyg4jEVkBXANRhAiUyZ0c’

I just wanted to check that with assigning credentials.headers.Authorization was not cut/modified anyway...

I tried to modify routes/api.php that unremove method must be BEFORE resource, like:

Route::put('tasks/{id}/unremove', 'API\Admin\[email protected]_task'); 
Route::resource('tasks', 'API\Admin\TaskController'); ?

That did not help. I got the same 401 error.

Any ideas why error ?

May
23
2 months ago
Activity icon

Started a new Conversation I Got 401 Error In Undelete Method Of Vue Request?

Hello, I make @vue/cli 4.0.5 app with reading data from Laravel 7 Backend REST API and and with softly deletion functionality in frontend part I have 2 methods 1) delete row 2) undelete row Making similar implementation for both cases I got 401 error in 2) case and I can not find why.

  1. Deleting row(works ok):
            removeTask(id, task_name, soft_deletion/*, index*/) {
                console.log('removeTask soft_deletion::')
                console.log(soft_deletion)

                let confirm_message= "Do you want to delete permanently " + " '" + task_name + "' task ? It can not be restored !"
                if (soft_deletion) {
                    confirm_message= "Do you want to mark for deletion " + " '" + task_name +
                        "' task ? It would be unavailable in the app, but can be restored(undeleted) OR deleted permanently !"
                }

                if (!confirm(confirm_message)) {
                    return
                }

                let credentials= this.credentialsConfig
                credentials.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken
                console.log('removeTask credentials::')
                console.log(credentials)

                axios.delete(this.apiUrl + '/adminarea/tasks/' + id, credentials).then((/*response*/) => {
                    this.loadTasks()
                    this.showPopupMessage('Tasks Editor', 'Task was '+(soft_deletion ? "softly" : "permanently")+' deleted successfully !'+( soft_deletion ?
                        "But you can restore it or delete permanently" : "" ), 'success')
                }).catch((error) => {
                    console.error(error)
                    this.showPopupMessage('Tasks Editor', 'Error deleting task : ' + error.response.data.message, 'error')
                })

            }, //removeTask(id, task_name, soft_deletion, index) {

and I see in console: https://imgur.com/a/e1vruhv

  1. Undeleting row (raise 401 error)
            unremoveTask(id, task_name/*, index*/) {
                console.log('unremoveTask id::')
                console.log(id)

                if (!confirm("Do you want to restore(undelete) " + " '" + task_name + "' task ?")) {
                    return
                }

                let credentials= this.credentialsConfig
                credentials.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken

                console.log('unremoveTask credentials::')
                console.log(credentials)

                axios.put(this.apiUrl + '/adminarea/tasks/' + id+"/unremove", credentials).then((/*response*/) => {
                    this.loadTasks()
                    this.showPopupMessage('Tasks Editor', 'Task was deleted successfully', 'success')
                }).catch((error) => {
                    console.error(error)
                    this.showPopupMessage('Tasks Editor', 'Error deleting task !', 'error')
                })

            }, //unremoveTask(id, task_name, index) {

and I see in console L https://imgur.com/a/YJ5DKWM

I do not understand why error in 2)? credentialsConfig if in settings file src/app.settings.js :

export const settingCredentialsConfig = {
    withCredentials:true,
    headers: {
        'Content-Type': 'application/json',
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Credentials':true
    }
}

and in my vue file :

<script>
    import {settingCredentialsConfig} from '@/app.settings.js'
    ...


data() {
    return {
    credentialsConfig: settingCredentialsConfig,
    ...

any time I got copy of credentialsConfig var and add token to it. In the console I see valid token headers.Authorization.

In /routes/api.php of my latavel app I have defined :

Route::group(['middleware' => 'jwt.auth',  'prefix' => 'adminarea', 'as' => 'adminarea.'], function ($router) {
    Route::resource('tasks', 'API\Admin\TaskController');
    Route::group([ 'prefix' => 'tasks'], function ($router) {
        Route::put('/{id}/unremove', 'API\Admin\[email protected]_task');

In case of incalid undelete url I got 404 error...

Why error and how it can be fixed?

Thanks!

May
22
2 months ago
Activity icon

Replied to How In Laravel 7 Notifications To Use Multiple Mail Driver?

This article 5 years ago. Seems format of config/mail.php has been changed from that time ? Or is this article is still valid could you please to point at issue ?

Activity icon

Started a new Conversation How In Laravel 7 Notifications To Use Multiple Mail Driver?

Hello, In laravel 7 app I use notifications for email sending, like:

    $newUser->notify(new SignupActivate($newUser, $site_name, $app_url));

Where app/Notifications/SignupActivate.php has :

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class SignupActivate extends Notification
{
    use Queueable;

    private $registeredUser;
    private $site_name;
    private $app_url;
    public function __construct($registeredUser, $site_name, $app_url)
    {
        $this->registeredUser= $registeredUser;
        $this->site_name= $site_name;
        $this->app_url= $app_url;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        ...

And with mail returned in via method. I search a way to use Multiple Mail Driver in this Notification

as is written on the link : https://laravel.com/docs/7.x/notifications#customizing-the-mailer


public function toMail($notifiable)
{
    return (new MailMessage)
                ->mailer('postmark')
                ->line('...');

But it does not work for me.

On config/mail.php I set 2 mailers :

<?php

return [


    'default' => env('MAIL_MAILER', 'sendgrid'),


    'mailers' => [
        'mailtrap' => [
           ...
        ],

        'sendgrid' => [
           ...
        ],

        
    ],
   ...

They both work ok if to change value in 'default'

But making in app/Notifications/SignupActivate.php :

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class SignupActivate extends Notification
{
    use Queueable;

    private $registeredUser;
    private $site_name;
    private $app_url;
    public function __construct($registeredUser, $site_name, $app_url)
    {
        $this->registeredUser= $registeredUser;
        $this->site_name= $site_name;
        $this->app_url= $app_url;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {

        return (new MailMessage)
            ->mailer('mailtrap') // ‘sendgrid’ does not work, 
            // if to enter some invalid value - it does not raise error - just ignored
            ->subject('Registration at ' . $this->site_name)
            ->line('Thanks for signup at '.$this->site_name.'!')
            ->line('To use our site, you must confirm your account at first.')
            ->action('Follow to Confirm Account', $url)
            ->line('Thank you for using our '.$this->site_name.' site !');
    }

    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

What is wrong ? Seems I did like in docs...

Laravel Framework 7.11.0

Thanks!

May
19
2 months ago
Activity icon

Started a new Conversation Why Complicated Scope With Subquery Does Not Work

Hello,

In my Laravel 5.7/ mysql app I make request on a storage_spaces table, which has client_id field(can be empty) which is reference to clients table. Any client can has several emails and there is client_additive_emails table with fields client_id and email I need by $search value with email entered (like 'hgedsaemail3.com' value) get all storage_spaces whose clients has entered emails in client_additive_emails. I have a complcated request where $filter_search is one of the parameters and it fails to find valid rows by entered email:

        $storageSpacesCollection = StorageSpace
            ::getByStatus($filter_status)
            ->whereRaw('storage_spaces.id <= 8') // DEBUGGING
            ->getById($relatedStorageSpacesArray)
            ->getByLocationId($filter_location_id, 'warehouses')
            ->getByCapacityCategoryId($filter_capacity_category_id, 'storage_capacities')
            ->getByLevel($filter_level)
            ->getByNumber($filter_number, true)
            ->orderBy('storage_spaces.id', 'asc')
            ->getByStorageCapacityId($filter_storage_capacity_id)
            ->getByClientId($filter_client_id)
            ->getByColorId($filter_color_id)
            ->getBySearch($filter_search) // THAT IS COMPLICATED SCOPE

            ->leftJoin( 'storage_capacities', 'storage_capacities.id', '=', 'storage_spaces.storage_capacity_id' )
            ->leftJoin( 'warehouses', 'warehouses.id', '=', 'storage_spaces.warehouse_id' )
            ->leftJoin( 'clients', 'clients.id', '=', 'storage_spaces.client_id')

            ->select(
                "storage_spaces.*",
                \DB::raw( "CONCAT(storage_capacities.count, ' ', storage_capacities.sqft ) as storage_capacity_name" ),
                \DB::raw("( SELECT check_ins.job_ref_no FROM check_ins WHERE check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id DESC limit 1 ) AS job_ref_no"),
                "warehouses.name as warehouse_name",
                "clients.id as client_id",
                \DB::raw( "CONCAT( clients.id, ' ', clients.full_name ) as client_full_name" ) )
            ->get();
search is impemented in scope with subquesry on emails search :
    public function scopeGetBySearch($query, $search = null)
    {
        if (empty($search)) {
            return $query;
        }
        $search_is_is_valid_float = with(new StorageSpace)->isValidFloat($search);

        $tb= with(new StorageSpace)->getTable();
        return $query->where(
            $tb.'.number',  $search
        ) ->orWhere(function ($query) use ($search, $tb, $search_is_is_valid_float) {
            $query->where( $tb.".notes",  'like',  '%'.$search.'%' )
                ->orWhere("clients.full_name", $search)
                ->orWhereRaw("(SELECT check_ins.job_ref_no FROM check_ins WHERE check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id ASC LIMIT 1) = '".$search."'");

            if($search_is_is_valid_float) {
                $query->orWhere("storage_capacities.count", $search);
                $query->orWhere($tb . ".selling_range", $search);
                $query->orWhere($tb . ".actual_storage_rent", $search);
                $query->orWhere($tb . ".insurance_vat", $search);
            } // if($search_is_is_valid_float) {


            // THAT SUBQUERY DOES NOT WORK:
            $query->orWhereIn('storage_spaces.client_id', function($query) use ($search){
                $query->select('client_additive_emails.client_id')
                      ->from("client_additive_emails")
                      ->where('client_additive_emails.client_id', "clients.id")
                      ->where('client_additive_emails.email', $search);
            });

and in sql-trace I see :

   SELECT `storage_spaces`.*, CONCAT(storage_capacities.count, ' ', storage_capacities.sqft )     AS storage_capacity_name, (   SELECT check_ins.job_ref_no 
    FROM check_ins 
    WHERE check_ins.storage_space_id=storage_spaces.id 
    ORDER BY check_ins.id DESC limit 1 )     AS job_ref_no, `warehouses`.`name`     AS `warehouse_name`, `clients`.`id`     AS `client_id`, CONCAT( clients.id, ' ', clients.full_name )     AS client_full_name 
    FROM `storage_spaces` 
    LEFT JOIN `storage_capacities` on `storage_capacities`.`id` = `storage_spaces`.`storage_capacity_id` 
    LEFT JOIN `warehouses` on `warehouses`.`id` = `storage_spaces`.`warehouse_id` 
    LEFT JOIN `clients` on `clients`.`id` = `storage_spaces`.`client_id` 
    WHERE storage_spaces.id <= 8     AND (`storage_spaces`.`number` = 'hgedsaemail3.com'     OR (`storage_spaces`.`notes` like '%hgedsaemail3.com%'     OR `clients`.`full_name` = 'hgedsaemail3.com'     OR (  SELECT check_ins.job_ref_no 
    FROM check_ins 
    WHERE check_ins.storage_space_id=storage_spaces.id 
    ORDER BY check_ins.id ASC LIMIT 1) = 'hgedsaemail3.com'     OR `storage_spaces`.`client_id` in (  SELECT `client_additive_emails`.`client_id` 
    FROM `client_additive_emails` 
    WHERE `client_additive_emails`.`client_id` = 'clients.id'     AND `client_additive_emails`.`email` = 'hgedsaemail3.com'))) 
    ORDER BY `storage_spaces`.`id` asc 

I try to debug the subquery with client id = 1885(if to run sql above without $search value entered then storage_spaces with client_id= 1885 is returned)

select *
 FROM `client_additive_emails` 
    WHERE `client_additive_emails`.`client_id` = 1885    AND 
`client_additive_emails`.`email` = 'hgedsaemail3.com'

It returns 1 rows as I expected

But I do not see why my request does not work ?

Thanks!

Activity icon

Awarded Best Reply on How To Make Laravel Eloquent Request With 1 Filter On Many Fields

I found a decision addin in scope :

    ->orWhereRaw("(SELECT check_ins.job_ref_no FROM check_ins WHERE
       check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id ASC LIMIT 1) = '".$search."'")

and that works for me.

Activity icon

Replied to How To Make Laravel Eloquent Request With 1 Filter On Many Fields

I found a decision addin in scope :

    ->orWhereRaw("(SELECT check_ins.job_ref_no FROM check_ins WHERE
       check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id ASC LIMIT 1) = '".$search."'")

and that works for me.

May
18
2 months ago
Activity icon

Replied to How To Make Laravel Eloquent Request With 1 Filter On Many Fields

I try to create sql I need mannually. With Laravel request :

        $storageSpacesCollection = StorageSpace
            ::getByStatus($filter_status)
            ->whereRaw('storage_spaces.id <= 8') // DEBUGGING
            ->getById($relatedStorageSpacesArray)
            ->getByLocationId($filter_location_id, 'warehouses')
            ->getByCapacityCategoryId($filter_capacity_category_id, 'storage_capacities')
            ->getByLevel($filter_level)
            ->getByNumber($filter_number, true)
            ->orderBy('storage_spaces.id', 'asc')
            ->getByStorageCapacityId($filter_storage_capacity_id)
            ->getByClientId($filter_client_id)
            ->getByColorId($filter_color_id)
            ->getBySearch($filter_search)

            ->leftJoin( 'storage_capacities', 'storage_capacities.id', '=', 'storage_spaces.storage_capacity_id' )
            ->leftJoin( 'warehouses', 'warehouses.id', '=', 'storage_spaces.warehouse_id' )
            ->leftJoin( 'clients', 'clients.id', '=', 'storage_spaces.client_id')
            ->select(
                "storage_spaces.*",

                \DB::raw( "CONCAT(storage_capacities.count, ' ', storage_capacities.sqft ) as storage_capacity_name" ),

                \DB::raw("( SELECT check_ins.job_ref_no FROM check_ins WHERE check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id ASC limit 1 ) AS job_ref_no"),

                "warehouses.name as warehouse_name",
                "clients.full_name as client_full_name")
            ->get();

And tracing I see sql statement with job_ref_no column :

   SELECT `storage_spaces`.*, CONCAT(storage_capacities.count, ' ', storage_capacities.sqft )     AS storage_capacity_name, (   SELECT check_ins.job_ref_no 
    FROM check_ins 
    WHERE check_ins.storage_space_id=storage_spaces.id 
    ORDER BY check_ins.id ASC limit 1 )     AS job_ref_no, `warehouses`.`name`     AS `warehouse_name`, `clients`.`full_name`     AS `client_full_name` 
    FROM `storage_spaces` 
    LEFT JOIN `storage_capacities` on `storage_capacities`.`id` = `storage_spaces`.`storage_capacity_id` 
    LEFT JOIN `warehouses` on `warehouses`.`id` = `storage_spaces`.`warehouse_id` 
    LEFT JOIN `clients` on `clients`.`id` = `storage_spaces`.`client_id` 
    WHERE storage_spaces.id <= 8     AND (`storage_spaces`.`number` = '999'     OR 
  
      (`storage_spaces`.`notes` like '%999%'     OR 
       `storage_spaces`.`selling_range` = '999'     OR 
       `storage_spaces`.`actual_storage_rent` = '999'     OR 
       `storage_spaces`.`insurance_vat` = '999') ) 
    ORDER BY `storage_spaces`.`id` asc 

I want to set filter on job_ref_no column manually :

   SELECT `storage_spaces`.*, CONCAT(storage_capacities.count, ' ', storage_capacities.sqft )     AS storage_capacity_name, (   SELECT check_ins.job_ref_no 
    FROM check_ins 
    WHERE check_ins.storage_space_id=storage_spaces.id 
    ORDER BY check_ins.id ASC limit 1 )     AS job_ref_no, `warehouses`.`name`     AS `warehouse_name`, `clients`.`full_name`     AS `client_full_name` 
    FROM `storage_spaces` 
    LEFT JOIN `storage_capacities` on `storage_capacities`.`id` = `storage_spaces`.`storage_capacity_id` 
    LEFT JOIN `warehouses` on `warehouses`.`id` = `storage_spaces`.`warehouse_id` 
    LEFT JOIN `clients` on `clients`.`id` = `storage_spaces`.`client_id` 
    WHERE storage_spaces.id <= 8     AND (`storage_spaces`.`number` = '999'     OR 
  
      (`storage_spaces`.`notes` like '%999%'     OR 
       `storage_spaces`.`selling_range` = '999'     OR 
       `storage_spaces`.`actual_storage_rent` = '999'     OR 
       `storage_spaces`.`insurance_vat` = '999' OR 
       job_ref_no = '999' )   // I added this line @
     ) 
    ORDER BY `storage_spaces`.`id` asc 

But I got error :

Error in query (1054): Unknown column 'job_ref_no' in 'where clause'

Which is valid way in raw sql and how it can be implemented with eloquent ?

May
17
2 months ago
Activity icon

Started a new Conversation How To Make Laravel Eloquent Request With 1 Filter On Many Fields

Hello,

In my Laravel 5.7/ mysql app I make request on a form with 10 filter inputs, one of them ($filter_search) if non empty must be compared with all fields(string, number, date, ref to fields of other tables) in resulting listing.

I made scope on this table fields:

    public function scopeGetBySearch($query, $search = null)
    {
        if (empty($search)) {
            return $query;
        }
        $tb= with(new StorageSpace)->getTable();
        return $query->where(
            $tb.'.number',  $search
        ) ->orWhere(function ($query) use ($search, $tb) {
            $query->where( $tb.".notes",  'like',  '%'.$search.'%' )
                ->orWhere($tb.".selling_range", $search)
                    ->orWhere($tb.".actual_storage_rent", $search)
                        ->orWhere($tb.".insurance_vat", $search)
//                            ->havingRaw("job_ref_no", $search)

        })

But I have a problem how can I set filter on job_ref_no field from other table :

     $storageSpacesCollection = StorageSpace
            ::getByStatus($filter_status)
            ->getById($relatedStorageSpacesArray)
            ->getByLocationId($filter_location_id, 'warehouses')
            ->getByCapacityCategoryId($filter_capacity_category_id, 'storage_capacities')
            ->getByLevel($filter_level)
            ->getByNumber($filter_number, true)
            ->orderBy('storage_spaces.id', 'asc')
            ->getByStorageCapacityId($filter_storage_capacity_id)
            ->getByClientId($filter_client_id)
            ->getByColorId($filter_color_id)
            ->getBySearch($filter_search)

//            ->havingRaw("job_ref_no = " . $filter_search)

            ->leftJoin( 'storage_capacities', 'storage_capacities.id', '=', 'storage_spaces.storage_capacity_id' )
            ->leftJoin( 'warehouses', 'warehouses.id', '=', 'storage_spaces.warehouse_id' )
            ->leftJoin( 'clients', 'clients.id', '=', 'storage_spaces.client_id')
            ->select(
                "storage_spaces.*",

                \DB::raw( "CONCAT(storage_capacities.count, ' ', storage_capacities.sqft ) as storage_capacity_name" ),

                \DB::raw("( SELECT check_ins.job_ref_no FROM check_ins WHERE // I got job_ref_no field in subquesry  check_ins.storage_space_id=storage_spaces.id ORDER BY check_ins.id ASC limit 1 ) AS job_ref_no"),

                "warehouses.name as warehouse_name",
                "clients.full_name as client_full_name")
            ->get();

havingRaw does not work both in the scope and in the request above if to uncomment it.

  1. I tried to use addSelect, like:

But with request :

        $storageSpacesCollection = StorageSpace
            ::getByStatus($filter_status)
            ->whereRaw('storage_spaces.id <= 8') // DEBUGGING
            ->getById($relatedStorageSpacesArray)
            ->getByLocationId($filter_location_id, 'warehouses')
            ->getByCapacityCategoryId($filter_capacity_category_id, 'storage_capacities')
            ->getByLevel($filter_level)
            ->getByNumber($filter_number, true)
            ->orderBy('storage_spaces.id', 'asc')
            ->getByStorageCapacityId($filter_storage_capacity_id)
            ->getByClientId($filter_client_id)
            ->getByColorId($filter_color_id)
            ->getBySearch($filter_search)

//            ->havingRaw("job_ref_no = " . $filter_search)

            ->leftJoin( 'storage_capacities', 'storage_capacities.id', '=', 'storage_spaces.storage_capacity_id' )
            ->leftJoin( 'warehouses', 'warehouses.id', '=', 'storage_spaces.warehouse_id' )
            ->leftJoin( 'clients', 'clients.id', '=', 'storage_spaces.client_id')
            ->select(
                "storage_spaces.*",
                \DB::raw( "CONCAT(storage_capacities.count, ' ', storage_capacities.sqft ) as storage_capacity_name" ),
                "warehouses.name as warehouse_name",
                "clients.full_name as client_full_name")
            ->addSelect([
                'job_ref_no' => CheckIn::selectRaw('job_ref_no')->whereColumn('check_ins.storage_space_id', 'storage_spaces.id'),
            ])
            ->get();

I got an error:

 local.ERROR: stripos() expects parameter 1 to be string, object given {"userId":11,"email":"[email protected]","exception":"[object] (ErrorException(code: 0): stripos() expects parameter 1 to be string, object given at /mnt/_work_sdb8/wwwroot/lar/the-box-booking/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php:1031)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'stripos() expec...', '/mnt/_work_sdb8...', 1031, Array)
#1 /mnt/_work_sdb8/wwwroot/lar/the-box-booking/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php(1031): stripos(Object(Illuminate\Database\Eloquent\Builder), ' as ')
#2 [internal function]: Illuminate\Database\Query\Grammars\Grammar->wrap(Object(Illuminate\Database\Eloquent\Builder))

Which way is valid ?

Thanks!

May
15
3 months ago
Activity icon

Replied to How To Make Filtering On Client In Blade Listing Written With Jquery?

Actually I mean something different : like table with data on client with custom Filter inputs and custom columns for rows of data. Are there something like that ?

Activity icon

Started a new Conversation How To Make Filtering On Client In Blade Listing Written With Jquery?

Hello,

In my Laravel 5.7/jquey 3/ bootstrap 4 / mysql app I make in user's editor listing of clients and buttons to give/revoke access to any user.

I fill div in user's editor :

     <div class="tab-pane active" id="pills-related-user-access-clients" role="tabpanel"
         aria-labelledby="pills-related-user-access-clients" style="border:3px dotted blue;">
         <div id="div_related_user_access_clients" style="border:2px dotted green;"></div>
     </div>

When javascript is run :

backendUser.prototype.getUserRelatedUserAccessClients = function (user_id) {
    if ( typeof user_id == "undefined" ) return
    var href = '/admin/get-user-related-user-access-clients/' + user_id;
    $.ajax({
        type: "GET",
        dataType: "json",
        url: href,
        success: function (response) {
            $("#div_related_user_access_clients").html(response.html);
        },
        error: function (error) {
            popupErrorMessage(error.responseJSON.message)
        }

    });

} // function uploadUserDetailsInfo(user_id) {

and I use blade template for listing:

@if(count($clientsList) == 0)
    <h4 class="card-subtitle pl-2 pb-2">Has no clients in the system yet</h4>
@else
    <h4 class="card-subtitle pl-2 pb-2">Has {{ count($clientsList) }} clients, {{ $selected_user_access_clients_count }} selected for this user. </h4>

    <div class="table-responsive" style="max-height: 900px; overflow-y:auto; width: 100% !important;">
        <table class="table table-bordered table-striped text-primary ">
            @foreach($clientsList as $next_key => $nextRelatedClient)
                <tr>
                    <td>
                        {{$nextRelatedClient->client_id }}::{{ $nextRelatedClient->full_name }}
                    </td>
                    <td>

                        @if( !empty($nextRelatedClient->is_checked) )
                            <a href="#" onclick="javascript:backendUser.clearUserAccessClientToUser({{$nextRelatedClient->client_id }},'{{$nextRelatedClient->full_name }}')">
                                <i class="fa fa-remove"></i>Revoke Access
                            </a>
                            <b>&nbsp;&nbsp;Selected</b>&nbsp;
                        @else
                            <a href="#" onclick="javascript:backendUser.attachUserAccessClientToUser({{$nextRelatedClient->client_id }},
                                '{{$nextRelatedClient->full_name }}')">
                                <i class="fa fa-paperclip"></i>Give Access
                            </a>
                        @endif

                    </td>

                </tr>
            @endforeach

        </table>
    </div>

@endif

Also I am going to add checkbox near with any client to make group operations. It works for me, but clients listing is rather big(more 1000 items). Are there some tools to make search filter on client's side(no on server) ? At least 1 input for client name but with possibility to add filter inputs/checkbox, selection ? Also if some filter is applied not to lose group selections I have at this moment.

Thanks!

May
10
3 months ago
Activity icon

Replied to How To Test Sendgrid Email With Mailtrap For Testing?

I founbd a link to video how to implement multiple mail drivers: https://www.youtube.com/watch?v=HCONO0cwsoI

I tried to follow it, but with I always got email at mailtrap.

Priorly, I worked with sendgrid and for this in file config/mail.php I wrote all sendgrid parameters. Now I want to write 2 emeil servers and fi=or this in .env I wrote:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=mailtrip_id
MAIL_PASSWORD=mailtrip_password

SENDGRID_HOST=smtp.sendgrid.net
SENDGRID_PORT=587
SENDGRID_ENCRYPTION=tls
SENDGRID_USERNAME=sendgrid_user
SENDGRID_PASSWORD=sendgrid_user_password

and I remade config/mail.php (I got a sample from https://github.com/laravel/laravel/blob/master/config/mail.php):

<?php
return [


    'driver' => env('MAIL_DRIVER', 'smtp'),


    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),


    'port' => env('MAIL_PORT', 587),


    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hel[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],


    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME'),

    'password' => env('MAIL_PASSWORD'),

    'sendmail' => '/usr/sbin/sendmail -bs',

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

    'log_channel' => env('MAIL_LOG_CHANNEL'),

    'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST'),
            'port' => env('MAIL_PORT'),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

        'sendgrid' => [
            'transport' => 'sendgrid',
            'host' => env('SENDGRID_HOST', 'smtp.sendgrid.net'),
            'port' => env('SENDGRID_PORT', 587),
            'encryption' => env('SENDGRID_ENCRYPTION', 'tls'),
            'username' => env('SENDGRID_USERNAME'),
            'password' => env('SENDGRID_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

        'ses' => [
            'transport' => 'ses',
        ],

        'mailgun' => [
            'transport' => 'mailgun',
        ],

        'postmark' => [
            'transport' => 'postmark',
        ],

        'sendmail' => [
            'transport' => 'sendmail',
            'path' => '/usr/sbin/sendmail -bs',
        ],

        'log' => [
            'transport' => 'log',
            'channel' => env('MAIL_LOG_CHANNEL'),
        ],

        'array' => [
            'transport' => 'array',
        ],
    ],

];

I am not sure that this config file is valid? Are mail config parameters are read from mailers array ? Looks like default(mailtrip) mail config is used always. Is it invalid format ?

In my control I do:

        $email_mode= 'live';
//        $email_mode= 'debug';

        if( $email_mode== 'debug' ) {
            \Log::info( '-10 Send to mailtrap ::' );

            \Mail
                ::mailer('smtp')
                ->to('[email protected]') // DEBUG
                ->send(new TestEmail);  // 
            \Log::info( '-10 Send to mailtrap AFTER::' );
        }

        // sendgrid
        if( $email_mode== 'live') {
            \Log::info( '-11 Send to sendgrid ::' );
            \Mail
                ::mailer('sendgrid')
                ->to('[email protected]') // DEBUG
                ->send(new SendgridMail('emails/contact_us_was_sent', $newContactUs->author_email, '', $subject, $additiveVars, $attachFiles));
            \Log::info( '-11 Send to sendgrid AFTER::' );
        }

I check in logs that live flow is run but anyway I got email at mailtrap.