PetroGromovo

PetroGromovo

Member Since 1 Year Ago

Experience Points
5,180
Total
Experience

4,820 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
1
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 2
5,180 XP
Aug
13
2 days ago
Activity icon

Replied to How Can I Generate Access Error And Error Message, Leaving User On The Page?

Let me explain it with detailed example :

In laravel / jquery apps I have in JS code :

    var quiz_quality_radio= $('input[name=quiz_quality_radio]:checked').val()
    var href = this_frontend_home_url + "/make-quiz-quality";
    $.ajax( {
        type: "POST",
        dataType: "json",
        url: href,
        data: {"quiz_quality_id": quiz_quality_radio, "vote_id": this_vote_id, "_token": this_csrf_token},
        success: function( response )
        {
            $('input[name=quiz_quality_radio]:checked').prop('checked', false);
            frontendVote.showQuizQualityResults()
            popupAlert("Thank you for rating ! Your rate was added!", 'success')
        },
        error: function( error )
        {
            $('input[name=quiz_quality_radio]:checked').prop('checked', false);
            popupAlert(error.responseJSON.message, 'danger') // 'info', 'success'
        }
    });

and relative action in control :

public function make_quiz_quality(Request $request)
{
    $requestData     = $request->all();
    $quiz_quality_id = ! empty($requestData['quiz_quality_id']) ? $requestData['quiz_quality_id'] : '';
    $vote_id         = ! empty($requestData['vote_id']) ? $requestData['vote_id'] : '';

    if ( ! Auth::check()) {
        return response()->json(['message' => "To rate you must login to the system !"], HTTP_RESPONSE_BAD_REQUEST);
    }
    if (empty($quiz_quality_id)) {
        return response()->json([
            'message'         => "To rate you must select quiz quality !",
            'quiz_quality_id' => $quiz_quality_id
        ], HTTP_RESPONSE_OK);
    }

    $vote = Vote::find($vote_id);
    if ($vote === null) {
        return response()->json([ 'message' => "Vote Item # " . $vote_id . " not found !"],HTTP_RESPONSE_NOT_FOUND);
    }
    $loggedUser = Auth::user();

    $found_count = QuizQualityResult
        ::getByVoteIdAndUserId($vote_id, $loggedUser->id)
        ->count();
    if ($found_count > 0) {
        return response()->json(['message' => "You have already rated '" . $vote->name . "' # vote !", 'vote_id' => $vote_id],
            HTTP_RESPONSE_BAD_REQUEST);
    }

    $newVoteItemUsersResult = new QuizQualityResult();
    try {
        $newVoteItemUsersResult->quiz_quality_id = $quiz_quality_id;
        $newVoteItemUsersResult->vote_id         = $vote_id;
        $newVoteItemUsersResult->user_id         = $loggedUser->id;
        DB::beginTransaction();
        $newVoteItemUsersResult->save();

        $newActivityLog              = new ActivityLog();
        $newActivityLog->description = $loggedUser->username . ' set quiz quality ' . ($quiz_quality_id) . " on '" . $vote->name . "' vote ";
        $newActivityLog->subject_id  = $requestData['vote_id'];
        $newActivityLog->causer_id   = $loggedUser->id;
        $newActivityLog->log_name    = $loggedUser->username;
        $newActivityLog->causer_type = ActivityLog::CAUSER_TYPE_SET_QUIZ_QUALITY;
        $newActivityLog->properties  = $quiz_quality_id;
        $newActivityLog->save();

        DB::commit();
    } catch (Exception $e) {
        DB::rollBack();

        return response()->json(['message' => $e->getMessage(), 'voteCategory' => null], HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
    }

    return response()->json(['message' => '', 'id' => $newVoteItemUsersResult->id], HTTP_RESPONSE_OK_RESOURCE_CREATED);
} //     public function make_quiz_quality(Request $request)

and in case of error generated in error block I show message with function popupAlert (implemented with bootstrapGrowl), without leaving the page. That is what I want to make in livewire / turbolinks / alpine app. How can I do it?

Aug
11
4 days ago
Activity icon

Replied to How Can I Use Variables In Blade File From _variables.scss?

Thanks, it looks like what I need , but has several possible decisions. Firstly I tried this https://www.npmjs.com/package/sass-to-js but trying to use it I got error :

Call to undefined function sassToJs

I installed package with command :

 yarn add  sass-to-js

Next in the file resources/views/layouts/app.blade.php I added line :

    <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="sass-to-js/js/dist/sass-to-js.min.js"></script>
    
    <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"></script>
    <script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>
    
    @livewireScripts
    @stack('styles')

I hope that is valid place for sass-to-js.min.js

and in resources/views/livewire/auth/profile.blade.php I added :

</article> <!-- page_content_container -->

<style>
    @import "sass-to-js/sass/sass-to-js";

    @import '/resources/sass/_variables.scss';
    
    
    .input_group_label {
        @if (sassToJs($debug_mode))
            border: 2px dotted green;
        @endif
        width: 25%;
    }
    

</style>

What is wrong ? Which decision is valid ?

Activity icon

Started a new Conversation How Can I Use Variables In Blade File From _variables.scss?

Hello, In resources/sass/app.scss file of laravel 7 app I try to reference variables defined in resources/sass/_variables.scss as :

@import 'variables';
...
.input_group_label {
    @if ($debug_mode) {
        border: 2px dotted green ;
    }
    @endif
    width: 25%;
}

But I got error :

Undefined variable: debug_mode 

debug_mode var is defined in resources/sass/_variables.scss :

...
$debug_mode: false;

What is wrong ?

Thanks!

Aug
09
6 days ago
Activity icon

Replied to How Can I Generate Access Error And Error Message, Leaving User On The Page?

Thanks, I will try this way, how to show error message on client, without other page redirecting?

Activity icon

Started a new Conversation How Can I Generate Access Error And Error Message, Leaving User On The Page?

Hello, In laravel / jquery apps if I need to make checks if user is logged I make in controller:

  $loggedUser = Auth::user();
     if ( empty($loggedUser->id) ) {
         return response()->json(['error_code'=> 1, 'message'=> "You must be logged!"],HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
     }

as I do not need to leave the user from the page, but only restrict some functionality I show error message above using bootstrapGrowl library. Now with laravel 7 /livewire 1.3 / turbolinks:5 / [email protected] I search how can I generate error and show similar error message, leaving user on the page ?

Thanks!

Aug
01
2 weeks ago
Activity icon

Started a new Conversation In Livewire App To Show Sweet-alert Message When Other Page With Turrbolinks

Hello, In laravel 7 with livewire 1.3 / turbolinks:5.2 / [email protected] aoo I added realrashid/sweet-alert 3.1 and testing it in component render, like

public function render()
{
    Alert::alert('Title', 'Message222', 'Type');
    ...
    

I found that message alert is shown if I reload page with F5. If I open other page with turrbolinks the alert is not shown. If there is a way to show this alert other page with turrbolinks ? maybe with some other library ?

Thanks!

Jul
08
1 month ago
Activity icon

Replied to With Html2pdf In Generated Pdf As All Css Styles Are Lost

Looking at hint [email protected] in my blade form I changed refering to my css :

    <link rel="stylesheet" href="{{ public_path('/css/flb_layout.css') }}">

As result my css classes are not rendered in the page of the browser. In generated pdf file my css classes are not rendered too.

In my project I use webpack.mix.js with definitions:

const mix = require('laravel-mix');


let current_admin_template= 'Backend';
mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/' + current_admin_template + '/backend.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_lg.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_md.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_sm.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_xs_320.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_xs_480.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/' + current_admin_template + '/style_xs_600.scss', 'public/css/' + current_admin_template)
    .sass('resources/sass/debug.scss',  'public/css' )
;

Can it be used anyway?

Jul
07
1 month ago
Activity icon

Replied to With Html2pdf In Generated Pdf As All Css Styles Are Lost

I created file public/css/flb_layout.css with all flexbox classes definitions and in my blade file I added asset to this css file:

@section('scripts')


    <link rel="stylesheet" href="{{ asset('/css/gijgo.min.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ asset('/css/flb_layout.css') }}" type="text/css">
    ...

and checking source of generated html file I see link to flb_layout.css file:

    </footer>
    <link rel="stylesheet" href="http://local-boxbooking2.com/css/gijgo.min.css" type="text/css">
    <link rel="stylesheet" href="http://local-boxbooking2.com/css/flb_layout.css" type="text/css">

where http://local-boxbooking2.com - is hosting of my local app.

and as result in my browser I see that flexbox layout is rendered ok, but generating pdf file I see plain html without flexbox classes definitions applied. Which way is valid ?

Jul
06
1 month ago
Activity icon

Replied to With Html2pdf In Generated Pdf As All Css Styles Are Lost

I think yes, as when I use in html code in style definition flexbox elements - it works ok. But problem if I try to define css classes with flexbox elements. Or better to say css classes are not accessible in generated pdf

Activity icon

Replied to With Html2pdf In Generated Pdf As All Css Styles Are Lost

Do you mean that I have to cut styles definitions from blade file :

   <style  lang="css">
        .flexbox-parent
        {
           ...
        }

        .flexbox-item
        {
           ...
        }
        ...

    </style>

and 1) to put them in new css file? 2) In my blade file make absolute path to this css file ?

Jul
05
1 month ago
Activity icon

Started a new Conversation With Html2pdf In Generated Pdf As All Css Styles Are Lost

Hello, In my laravel 5.7 / bootstrap 4.4 app I use spatie/browsershot 3.37 and spipu/html2pdf 5.2 to generate pdf file and for my generated pdf file want I set layout with 100% height and footer and header like here: https://jsfiddle.net/MadLittleMods/LmYay/

But imported block of code which looks ok on my blade page in browser is invalid in generated pdf : as all css styles are lost.

by clicking on “To pdf file” content of the page is rendered into pdf file:

        Browsershot::html(htmlspecialchars_decode($pdf_content))
                   ->showBackground()
                   ->save($save_to_file);

        if($hidden_action== 'upload') {
            \Response::download($save_to_file, $filename_to_save, array('Content-Type: application/octet-stream', 'Content-Length: pdf'));
            return response()->download($save_to_file, $filename_to_save)->deleteFileAfterSend(true);
        }

in my blade file:

@extends($current_admin_template.'.layouts.backend')


@section('content')

    @inject('viewFuncs', 'App\library\viewFuncs')

    <div id="page-wrapper" class="card">


  // THIS PART LOOKS OK IN BROWSER BUT IN GENERATED PDF INVALID AS ALL CSS CLASSES ARE LOST
        <div class="flexbox-parent" id="div_invoice_content" style="display: flex;">
            <input type="hidden" id="hidden_invoice_no" name="hidden_invoice_no" value="{{$invoice_no}}">
            <input type="hidden" id="hidden_invoice_id" name="hidden_invoice_id" value="{{$invoice_id}}">

            <div class="flexbox-item header">
                Header $invoice_no::{{$invoice_no}}<br>
                $invoice_id::{{$invoice_id}}
            </div>

            <div class="flexbox-item fill-area content flexbox-item-grow">
                <div class="fill-area-content flexbox-item-grow">
                    Content
                    <br /><br />
                    Emulates height 100% with a horizontal flexbox with stretch
                    <br /><br />
                    This box with a border should fill the blue area except for the padding (just to show the middle flexbox item).
                </div>
            </div>

            <div class="flexbox-item footer">
                Footer
            </div>
        </div>


        <form method="POST" action="{{ url('/admin/generate-pdf-by-content') }}" accept-charset="UTF-8" id="form_print_to_pdf_content"
              name="form_print_to_pdf_content"
              enctype="multipart/form-data">
            {!! csrf_field() !!}

            <div class="form-row m-3">
            ...
            FORM CONTENT
            ...
            

            </div>
        </section> <!-- class="card-body" -->

    </div>
    <!-- /.page-wrapper page Content : invoice edit -->


@endsection



{{[email protected]('head')--}}
{{[email protected]('scripts')--}}
    <style  lang="css">
        .flexbox-parent
        {
            height: 842pt !important;
            width: 595pt !important;

            display: flex;
            flex-direction: column;

            justify-content: flex-start; /* align items in Main Axis */
            align-items: stretch; /* align items in Cross Axis */
            align-content: stretch; /* Extra space in Cross Axis */

            background: rgba(255, 255, 255, .1);
        }

        .flexbox-item
        {
            padding: 8px;
        }
        .flexbox-item-grow
        {
            flex: 1; /* same as flex: 1 1 auto; */
        }

        .flexbox-item.header
        {
            background: rgba(255, 0, 0, .1);
        }
        .flexbox-item.footer
        {
            background: rgba(0, 255, 0, .1);
        }
        .flexbox-item.content
        {
            background: rgba(0, 0, 255, .1);
        }

        .fill-area
        {
            display: flex;
            flex-direction: row;

            justify-content: flex-start; /* align items in Main Axis */
            align-items: stretch; /* align items in Cross Axis */
            align-content: stretch; /* Extra space in Cross Axis */

        }
        .fill-area-content
        {
            background: rgba(0, 0, 0, .3);
            border: 1px solid #000000;

            /* Needed for when the area gets squished too far and there is content that can't be displayed */
            overflow: auto;
        }
    </style>
{{[email protected]}}

{{[email protected]}}




@section('scripts')


    <link rel="stylesheet" href="{{ asset('/css/gijgo.min.css') }}" type="text/css">

    <script src="{{ asset('js/AutoNumeric/[email protected]') }}"></script>
    ...

@endsection

I tried to put <style block in several places of the page, but in all cases in generated pdf as all css styles are lost

Which is valid way to use css classes in the generated file?

Thanks!

Jul
02
1 month ago
Activity icon

Started a new Conversation Uploading My Vuejs 2 Project Can I Automatically Create .htaccess?

Hello, Uploading my vuejs 2 project on my ubuntu server after I run app building command

yarn run build

I need anytime manually to run command :

sudo nano  /var/www/html/ads/dist/.htaccess

and fill the file with content :

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

as I need to open my server pages from any url, like

my-hosting/site/page-of-site

If there is a way to automize this ?

Thanks!

Jun
13
2 months ago
Activity icon

Started a new Conversation Rules For Imask-input To Fill Latitude Value

Hello, In bootstrap-vue app I need to make editor for Latitude / longitude and I added https://github.com/uNmAnNeR/imaskjs for my projectm but it does not work as I expect with mask :

                <imask-input
                        v-model="number_lat"
                        :mask="Number"
                        radix="."
                        :unmask="false"
                        :scale="7"
                        :signed="false"
                        @accept="onAccept"
                        placeholder='Enter latitude here'
                        :from="-90"
                        :to="90"
                />

and data definition :

        data() {
            return {
                number_lat: 51.503,

I got error on page opened :

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in mounted hook: "Error: value should be string"

and the rules do not permit to enter negative value and rage from to do not work.

Which is the valid way ?

    "bootstrap-vue": "^2.3.0",
    "store": "^2.0.12",
    "v-money": "^0.8.1",
    "vee-validate": "^3.2.1",
    "verte": "0.0.12",
    "vue": "^2.6.11",
    "vue-imask": "^6.0.5",

Thanks!

Jun
12
2 months ago
Activity icon

Started a new Conversation Rules To Fill Latitude Value With Imaskjs

Hello, In bootstrap-vue app I need to make editor for Latitude / longitude and I added https://github.com/uNmAnNeR/imaskjs for my projectm but it does not work as I expect with mask :

                number_lat::{{ number_lat}}<br>
                <imask-input
                        v-model="number_lat"
                        :mask="Number"
                        radix="."
                        :unmask="false"
                        :scale="7"
                        :signed="false"
                        @accept="onAccept"
                        placeholder='Enter latitude here'
                        :from="-90"
                        :to="90"
                />

and data definition :

        data() {
            return {
                number_lat: 51.503,

I got error on page opened :

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in mounted hook: "Error: value should be string"

and the rules do not permit to enter negative value and rage from to do not work.

Which is the valid way ?

    "bootstrap-vue": "^2.3.0",
    "store": "^2.0.12",
    "v-money": "^0.8.1",
    "vee-validate": "^3.2.1",
    "verte": "0.0.12",
    "vue": "^2.6.11",
    "vue-imask": "^6.0.5",

Thanks!

Jun
04
2 months ago
Activity icon

Started a new Conversation With Leaflet In Bootstrap-vue Remove Default Dialog Popup On Marker's Click

Hello, In vue/ bootstrap-vue app with leaflet 1.6.0 I make custom modal dialog on marker clicking and I can not remove default dialog popup. I do

                let nextMarker = this.leaflet.marker(
                    [nextLocationPoint.lat, nextLocationPoint.lng], {icon: markerIcon})
                    .addTo(locationsMap)
                    .bindPopup(nextLocationPoint.title)
                    .on('mouseover', this.locationMarkerOnMouseOver)
                    .on('click', this.locationMarkerOnClick)  

        methods: {

            locationMarkerOnClick(e) {
                console.log('locationMarkerOnClick e::')
                console.log(e)

                // e.stopPropagation()  // THIS RAISE ERROR
                // e.preventDefault()  // THIS RAISE ERROR
                
                e.cancelBubble = true
                window.event.cancelBubble = true  // NOTHING OF THESE METHODS
                window.event.preventDefault(e)
                window.event.stopPropagation()

                this.$bvModal.show('viewAdLocationModal')

                return false
            }, // locationMarkerOnClick(e) {

I know that in vuejs syntax like :

<div @click.stop.prevent.self="">

OR

@click.prevent="handleClick"

But if it can be used for my case with leaflet?

How to fix this issue?

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

Thanks!

May
25
2 months ago
Activity icon

Started a new Conversation Mapping With Elasticquent Got Root Mapping Definition Has Unsupported Parameters Error

Hello, In Laravel 7.12.0 app I added "elasticquent/elasticquent": "dev-master" plugin and I try to implement sample data example from https://www.elastic.co/blog/a-practical-introduction-to-elasticsearch

with shakespeare.json file

But making mapping I got error :

Elasticsearch\Common\Exceptions\BadRequest400Exception
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [shakespeares : {_source={enabled=true}, properties={play_name={analyzer=standard, type=string}, speech_number={analyzer=standard, type=number}, line_number={analyzer=standard, type=string}, text_entry={analyzer=standard, type=text}, speaker={analyzer=standard, type=string}, line_id={analyzer=standard, type=integer}}}]"}},"status":400}

I created model /app/Shakespeare.php :

<?php

namespace App;

use DB;
use Illuminate\Database\Eloquent\Model;
use App\library\MyFuncsClass;

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
use Elasticquent\ElasticquentTrait;

class Shakespeare extends Model
{
    use ElasticquentTrait;
    protected $table = 'shakespeares';
    protected $primaryKey = 'id';
    public $timestamps = false;

    protected $mappingProperties = array(
/*        'title' => array(
            'type' => 'string',
            'analyzer' => 'standard'
        )*/
        'line_id' => [
            'type' => 'integer',
            'analyzer' => 'standard'
        ],

        'play_name' => [
            'type' => 'string',
            'analyzer' => 'standard' // not_analyzed
        ],

        'speech_number' => [
            'type' => 'number',
            'analyzer' => 'standard'
        ],


        'line_number' => [
            'type' => 'string', // line_number??
            'analyzer' => 'standard'
        ],

        'speaker' => [
            'type' => 'string',
            'analyzer' => 'standard' // not_analyzed
        ],


        'text_entry' => [
            'type' => 'text',
            'analyzer' => 'standard'
        ],

    );



    protected $fillable = [
        'id', 'line_id', 'play_name', 'speech_number', 'line_number', 'speaker', 'text_entry', 'created_at', 'updated_at'
    ];

    function getIndexName()
    {
        return 'shakespeares_root';
    }

    public static function setESMapping()
    {
//        if (   Shakespeare::mappingExists() ) {
//        Shakespeare::deleteMapping();
//        }


        // Error pointing to line below !
        $ret= Shakespeare::createIndex(/*$shards = null, $replicas = null*/);
        \Log::info( '-1 setESMapping $ret ::' . print_r(  $ret, true  ) );

        $ret= Shakespeare::putMapping( true/*$ignoreConflicts = true*/);
        \Log::info( '-2 setESMapping $ret ::' . print_r(  $ret, true  ) );

        $ret= Shakespeare::addAllToIndex();
        \Log::info( '-3 setESMapping $ret ::' . print_r(  $ret, true  ) );

my config/elasticquent.php :

<?php

return array(
    'config' => [
        'hosts'     => ['localhost:9200'],
        'retries'   => 1,
    ],

    'default_index' => 'my_custom_index_name',

);

elasticsearch is running at the moment and I have in console :

 curl localhost:9200
{
  "name" : "athoe",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "e53SDZ6PTMyXhbeJ0Zx7TQ",
  "version" : {
    "number" : "7.7.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf",
    "build_date" : "2020-05-12T02:01:37.602180Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

I tried to hide columns in $mappingProperties , leaving only sample

'title' => array(
            'type' => 'string',
            'analyzer' => 'standard'
        )

But I have the same error. How to fix it ?

elasticsearch : Version: 7.7.0

Thanks!

May
22
2 months ago
Activity icon

Started a new Conversation How To Use Mixing In Cypress Of Vue/cli 4 App?

Hello, In vue/cli 4 app using cypress for testing I want to use my mixing and for this in my tests/e2e/specs/fileupload_tests.js I added declaration:

import faker from 'faker'
import 'cypress-file-upload'
import appMixin from '../../../src/appMixin'        // Full path is src/appMixin.js

describe('Admin category fileupload functionality', () => {
    it('category fileupload', () => {
        ...

But I see error in my browser :

/mnt/_work_sdb8/wwwroot/lar/VApps/vtasks/node_modules/@babel/runtime/helpers/esm/typeof.js:1
export default function _typeof(obj) {
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

That is not error of invalid mixing path - in this case I got different error.

Which way is valid ?

    "axios": "^0.19.0",
    "core-js": "^3.3.2",
    "cypress-file-upload": "^3.5.3",
    "vue": "^2.6.10",

Thanks!

May
11
3 months ago
Activity icon

Replied to Installed Mewebstudio/captcha Always Returned Invalid Capture

Thanks! It asks for INVISIBLE_RECAPTCHA_SECRETKEY. I have to get it on some external resource ?

Activity icon

Started a new Conversation Installed Mewebstudio/captcha Always Returned Invalid Capture

Hello! I installed mewebstudio/captcha in my Laravel 7.6 app but it always returned Invalid capture, even I enter valid value I enter in text inpur. Ex: entering https://prnt.sc/s8g03j and submitting form : I got

Invalid capture.

error. I try to debug info and see output from request validation in app/Http/Requests/ContactUsRequest.php with code :

    public function rules()
    {
        $request     = request();
        $requestData = $request->all();
        \Log::info( '-1 ContactUsRequest $requestData ::' . print_r(  json_encode($requestData), true  ) );

        \Log::info( '-2 contacts_us_post $request->session()->all(); ::' . print_r(  $request->session()->all(), true  ) );


        $a= ContactUs::getValidationRulesArray( [ 'skip_acceptor_id', 'skip_accepted'] );
        \Log::info( '-2 ContactUsRequest $a ::' . print_r(  $a, true  ) );
        return $a;
    }

When rules are defined in model :

    public static function getValidationRulesArray($options): array
    {
        $validationRulesArray = [
            'author_name'  => 'required|string|max:255',
            'author_email' => 'required|email|max:255',
            'message'      => 'required',
            'acceptor_id'  => 'required|integer|exists:' . (with(new User)->getTable()) . ',id',
            'accepted'     => 'required|in:' . with(new ContactUs)->getValueLabelKeys(ContactUs::getContactUsAcceptedValueArray(false)),
            'captcha'      => 'required|captcha'
        ];
        if (in_array('skip_acceptor_id', $options)) {
            unset($validationRulesArray['acceptor_id']);
        }
        if (in_array('skip_accepted', $options)) {
            unset($validationRulesArray['accepted']);
        }

        return $validationRulesArray;
    }

Checking logs I see :

[2020-04-30 10:29:12] local.INFO: -1 ContactUsRequest $requestData ::{"_token":"n8rVAUJhjg42hupGUntJZWwbOwzIcUmFYWna2e64","author_name":"[email protected]","author_email":"[email protected]","message":"text from [email protected] lorem\r\nipsum","captcha":"qtee7n"}  
[2020-04-30 10:29:12] local.INFO: -2 contacts_us_post $request->session()->all(); ::Array
(
    [_token] => n8rVAUJhjg42hupGUntJZWwbOwzIcUmFYWna2e64
    [_previous] => Array
        (
            [url] => http://local-votes.com/show_banner_image/1/PHP+site/php-logo.png/PHP+is+a+popular+scripting+language/2?dt=1588231599
        )

    [_flash] => Array
        (
            [old] => Array
                (
                )

            [new] => Array
                (
                )

        )

    [captcha] => Array
        (
            [sensitive] => 
            [key] => yt2.cC8CAPOd8JS8ZfcnUOeZr0RzD2eIDylRYurg41or1TpiEn7oS
        )

    [votes_register] => Array
        (
            [username] => JackParrot
            [email] => [email protected]
            [password] => 111111
            [first_name] => Jack
            [last_name] => Parrot
            [phone] => 098-765-4321
            [website] => jackparrot.vote_site.com
            [notes] => 
            [sex] => M
            [selectedSubscriptions] => Illuminate\Support\Collection Object
                (
                    [items:protected] => Array
                        (
                            [0] => 
                            [1] => 1
                            [2] => 2
                        )

                )

        )

)
  
[2020-04-30 10:29:12] local.INFO: -2 ContactUsRequest $a ::Array
(
    [author_name] => required|string|max:255
    [author_email] => required|email|max:255
    [message] => required
    [captcha] => required|captcha
)

I see my entered data in request and captcha data insession with key and I do not see error in captcha code code. Did I miss some options ?

My composer.json:

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": [
		"framework",
		"laravel"
	],
	"license": "MIT",
	"type": "project",

	"require": {
		"php": "^7.2.5",
		"alaouy/youtube": "^2.2",
		"aloha/twilio": "^4.0",
		"arrilot/laravel-widgets": "^3.12",
		"cornford/googlmapper": "^3.2.1",
		"cviebrock/eloquent-sluggable": "^7.0",
		"davejamesmiller/laravel-breadcrumbs": "5.x",
		"doctrine/dbal": "^2.8",
		"facebook/graph-sdk": "^5.7",
		"fideloper/proxy": "^4.0",
		"google/apiclient": "^2.4.1",
		"guzzlehttp/guzzle": "6.5.x-dev",
		"intervention/image": "^2.4",
		"itsgoingd/clockwork": "^3.0",
		"jrean/laravel-user-verification": "dev-master",
		"laravel/cashier": "^10.3",
		"laravel/framework": "^7.0",
		"laravel/passport": "^8.4",
		"laravel/tinker": "^2.0",
		"laravel/ui": "^2.0",
		"laravelium/sitemap": "7.0.1",
		"maatwebsite/excel": "^3.1",
		"mews/captcha": "^3.1",
		"mews/purifier": "3.2.0",
		"paypal/rest-api-sdk-php": "*",
		"pelago/emogrifier": "3.1.0",
		"proengsoft/laravel-jsvalidation": ">2.2.0",
		"qlick/laravel-full-calendar": "~1.0",
		"s-ichikawa/laravel-sendgrid-driver": "~2.0",
		"snowfire/beautymail": "dev-master",
		"spatie/browsershot": "^3.27",
		"spatie/db-dumper": "^2.14",
		"spatie/laravel-activitylog": "^3.1",
		"spatie/laravel-backup": "^6.1",
		"spatie/laravel-feed": "^2.1",
		"spatie/laravel-image-optimizer": "^1.4",
		"spatie/laravel-newsletter": "^4.2",
		"spatie/laravel-sitemap": "^5.3",
		"spatie/laravel-tags": "^2.1",
		"spipu/html2pdf": "^5.2",
		"stripe/stripe-php": "^7.2",
		"symfony/psr-http-message-bridge": "^1.2",
		"themsaid/laravel-mail-preview": "dev-master",
		"unisharp/laravel-filemanager": "^1.9",
		"wboyz/laravel-enum": "^0.2.1",
		"willvincent/feeds": "dev-master",
		"yajra/laravel-datatables-oracle": "^9.0.0",
		"zendframework/zend-diactoros": "^2.1"
	},

	"require-dev": {
		"barryvdh/laravel-debugbar": "^3.1",
		"filp/whoops": "^2.0",
		"fzaninotto/faker": "^1.4",
		"mockery/mockery": "^1.0",
		"nunomaduro/collision": "4.1",
		"orangehill/iseed": "^2.6",
		"phpunit/phpunit": "^8.5"
	},

	"repositories": [
		{
			"type": "vcs",
			"url": "https://github.com/jeremykenedy/Generators-1.git"
		}
	],

	"autoload": {
		"files": [
			"app/helper.php"
		],
		"classmap": [
			"database/seeds",
			"database/factories"
		],
		"psr-4": {
			"App\": "app/"
		}
	},
	"autoload-dev": {
		"psr-4": {
			"Tests\": "tests/"
		}
	},
	"extra": {
		"laravel": {
			"dont-discover": [
			]
		}
	},
	"scripts": {
		"post-root-package-install": [
			"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
		],
		"post-create-project-cmd": [
			"@php artisan key:generate"
		],
		"post-autoload-dump": [
			"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
			"@php artisan package:discover"
		],
		"post-update-cmd": [
			"php artisan vendor:publish --provider=\"Proengsoft\JsValidation\JsValidationServiceProvider\" --tag=public --force"
		]
	},
	"config": {
		"preferred-install": "dist",
		"sort-packages": true,
		"optimize-autoloader": true
	},
	"minimum-stability": "dev",
	"prefer-stable": true
}

How to fix it ?

Thanks!

Apr
26
3 months ago
Activity icon

Replied to If Output Of \Log::info Depens On Some Options?

Reading the doc by link I do not see that 'daily' means and to which value have I to change level ? Could, you please, explain?

Activity icon

Started a new Conversation If Output Of \Log::info Depens On Some Options?

Hello,

If output of

 \Log::info('text');

function is dependable on some options ?

in .env I have :

APP_DEBUG=false

and in config/app.php

    'debug' => env('APP_DEBUG', false),

Also in config/logging.php I have options(seems default):

<?php

use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [


    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily'],
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER'),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],
    ],

];

The quesion is that with my options on live server I expected

 \Log::info('text');

would not log lines, but it writes lines anyway.

I read here https://laravel.com/docs/5.7/logging do not see any dependencies.

I mean I need to have log messages only if APP_DEBUG=true. I suppose that must be default ? Laravel 5.7

Thanks!

Apr
24
3 months ago
Activity icon

Started a new Conversation Error In Vue-simple-suggest When Item Is Selected

Hello,

In my vue/cli 4 / Bootstrap 4.3 app I make suggestion component(using vue-simple-suggest) with some additive parameters and returning data I need to get slug field of selected row and to redirect to other page based on this slug. Search works ok for me, but when Item in selection list is selected I see in browsers console one more request to database with whole selected item object and that raise error. I make:

                            <vue-simple-suggest
                                    id="search_string"
                                    v-model="search_string"
                                    display-attribute="name"
                                    value-attribute="slug"
                                    :list="simpleSuggestionList"
                                    autocomplete=off
                                    mode="select"
                                    @select="taskSuggestionSelected()"
                            ></vue-simple-suggest>

and js code:

            simpleSuggestionList() {
                let filters={
                    search_string : this.search_string, // search
                    only_free : ( this.cbx_only_free ? 1 : 0), // additive parameters
                    price_min : this.tasksPriceRange[0],
                    price_max : this.tasksPriceRange[1],
                    selectedCategories : this.getSelectedCategories
                }
                console.log('filters::')
                console.log(filters)
                return axios.post(this.apiUrl + '/tasks-search', filters, this.credentialsConfig)
                    .then(({data}) => {
                        return data.tasks
                    })
                    .catch(error => {
                        console.error(error)
                        this.showPopupMessage('Tasks search', error.response.data.message, 'warn')
                    })

                // return this.retArray
            },


            taskSuggestionSelected() {
                console.log('\'taskSuggestionSelected par1 ::\'+par1 +"  search_string::"+this.search_string::')
                return false
            }
  1. Why error and how not to trigger request to server when item is selected and
  2. how can I save/ pass slug of selected item into taskSuggestionSelected method as I need to make redirection?
    "vue": "^2.6.10",
    "vue-simple-suggest": "^1.10.1",

Thanks!

Apr
22
3 months ago
Activity icon

Started a new Conversation Format For Resources Wrapper For Dates Returned From Settings Table

Hello, In laravel 6 app I make resources wrapper for dates returned from Settings table( pairs of name => value ), but I got returned data in invalid format, not pairs of name => value. I have in controller:

        $settingsArray= [];
        $settingValues              = Settings::getSettingsList();
        foreach( $settingValues as $nextSettingValue ) {
            $settingsArray[$nextSettingValue->name] = $nextSettingValue->value;
        }

        \Log::info('$settingsArray ::');
        \Log::info(print_r(  $settingsArray, true  ));

        return (new SettingsCollection($settingsArray));

Output of logging above is :

[2020-04-21 07:47:07] local.INFO: $settingsArray ::  
[2020-04-21 07:47:07] local.INFO: Array
(
    [site_name] => VTasks
    [copyright_text] => © 2019 - 2020 All rights reserved
    [site_heading] => Task 'em all
    [backend_items_per_page] => 2
    [tasks_per_page] => 4
    [events_per_page] => 5
    [events_demo_month] => 2018-02-01
)

and in app/Http/Controllers/API/Admin/SettingsController.php :

class SettingsCollection extends ResourceCollection
{

    public static $wrap = 'settings';

    public function toArray($request)
    {

          \Log::info('SettingsCollection $request::');
            \Log::info(print_r(  json_encode($request), true  ));

          \Log::info('+++ SettingsCollection $this::');
            \Log::info(print_r(  json_encode($this), true  ));


        return $this->collection->transform(function($settings, $key){
            \Log::info('+++ $settings:');
            \Log::info(print_r(  json_encode($settings), true  ));

            \Log::info('+++ $key:');
            \Log::info(print_r(  json_encode($key), true  ));

            return [
                $key => $settings,
            ];
        });

    }

I see in log output :

[2020-04-21 07:47:07] local.INFO: "tasks_per_page"  
[2020-04-21 07:47:07] local.INFO: +++ $settings:  
[2020-04-21 07:47:07] local.INFO: "5"  
[2020-04-21 07:47:07] local.INFO: +++ $key:  
[2020-04-21 07:47:07] local.INFO: "events_per_page"  
[2020-04-21 07:47:07] local.INFO: +++ $settings:  
[2020-04-21 07:47:07] local.INFO: "2018-02-01"  
[2020-04-21 07:47:07] local.INFO: +++ $key:  
[2020-04-21 07:47:07] local.INFO: "events_demo_month"  
[2020-04-21 07:47:07] local.INFO: {"site_name":{"site_name":"VTasks"},"copyright_text":{"copyright_text":"\u00a9 2019 - 2020 All rights reserved"},"site_heading":{"site_heading":"Task 'em all"},"backend_items_per_page":{"backend_items_per_page":"2"},"tasks_per_page":{"tasks_per_page":"4"},"events_per_page":{"events_per_page":"5"},"events_demo_month":{"events_demo_month":"2018-02-01"}}  

and returned data has wrong structure : https://imgur.com/a/CvIAAQO

Which is the valid way ?

Thanks!

Apr
13
4 months ago
Activity icon

Replied to Updating Profile In Swagger How Set Array Of Data

In app/Http/Controllers/API/PersonalController.php conrtoller of my backend app I added loging in update method:

    public function update(Request $request, $id)
    {
        $loggedUser = Auth::guard('api')->user();

        \Log::info('PersonalController update $this->requestData::');
        \Log::info(print_r(  $this->requestData, true  ));

        $loggedUser->first_name    = !empty($this->requestData['profile']['first_name']) ? $this->requestData['profile']['first_name'] : '';

and when update profile from my client @vue/cli 4.0.5 app I see logging like:

2020-04-13 03:28:10] local.INFO: PersonalController update $this->requestData:: [2020-04-13 03:28:10] local.INFO: Array ( [profile] => Array ( [first_name] => John [last_name] => Glads [phone] => 252-129-0916 [website] => [email protected] ) )

But when I make run update method from swagger I do not see any update logging string like above But I see 200 responce in swagger : https://prnt.sc/ry6con and in request : https://prnt.sc/ry6drl I suppose that I have invalid profile parameter, but I do not see why?

Apr
12
4 months ago
Activity icon

Started a new Conversation Updating Profile In Swagger How Set Array Of Data

Hello, In my @vue/cli 4.0.5 app I save my profile data as array of profile :

     axios.put(this.apiUrl + '/personal/profile/' + this.userProfileRow.id, {
         profile: {
             first_name: this.userProfileRow.first_name,
             last_name: this.userProfileRow.last_name,
             phone: this.userProfileRow.phone,
             website: this.userProfileRow.website
         },
     }, this.credentialsConfig).then((/*response*/) => {

and in console of browser I see PUT request with array

profile: {first_name: "a", last_name: "b", phone: "c", website: "d"}

Now I make description in swagger with api 3 version as :

  /personal/profile/{user_id}:
    put:
      tags:
        - profile
      summary: personal profile update editable fields

      responses:
        '200':
          description: Successful update
        '400':
          description: Invalid profile editable fields updating

      operationId: updateProfileEditableFieldsByBearerToken

      parameters:
        - name: user_id
          in: path
          description: The user_id update editable fields.
          required: true
          schema:
            type: integer
            default: 1
            example: 1

      requestBody:
        description: Editable fields
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                profile:
                  type: array
                  items:
                    $ref: '#/components/schemas/ProfileEditableFields'
                  
              required:
                - profile

components:

  schemas:

    ProfileEditableFields:
      properties:
        first_name:
          type: string
        last_name:
          type: string
        phone:
          type: string
        website:
          type: string

But I can not fill ProfileEditableFields, in my console I have : https://prnt.sc/rugv28

  1. I do not know which is valid format for any parameter of ProfileEditableFields ? With fhe fileld data above next curl request was generated :
curl -X PUT "http://myserver.com/api/personal/profile/1" -H "accept: */*" -H "Authorization: Bearer TOKEN" -H "Content-Type: application/x-www-form-urlencoded" -d "profile=first_name%20%3A%20111%0A%2Clast_name%20%3A%20222%0A%2Cphone%3A%20333333%2Cwebsite%3A%204444444"

But with 200 code returned all fields first_name, last_name... were cleared at db, as if empty values were sent(API permits empty fields).

  1. How can I set some default data for any elements of ProfileEditableFields structure ?

Thanks!

Apr
08
4 months ago
Activity icon

Started a new Conversation How To Add Additive Authorization Parameter In Vue-tables-2 Component Request

Implementing in my @vue/cli 4.0.5 app vue-tables-2 component with server-table and looking at this https://matanya.gitbook.io/vue-tables-2/server-table/custom-request-function

I try to set additive Authorization parameter to request like:

    <div id="activity_logs_data_table">
        <v-server-table url="/adminarea/activity-logs-filter" :columns="columns" :options="tableOptions">
            <span slot="edit" slot-scope="{row}">
                <a v-on:click="viewActivityLog(row)" :class="'p-1 a_view_item_'+row.id">
                    <i :class="'i_link '+getHeaderIcon('view')" title="View activity log item"></i>
                </a>
                <a v-on:click="removeActivityLog(row.id, row.log_name)" :class="'p-1 a_delete_item_'+row.id">
                  <i :class="'i_link '+getHeaderIcon('remove')" title="Remove activity log item"></i>
                </a>
            </span>
    
            <span slot="created_at" slot-scope="{row}">
                {{ momentDatetime(row.created_at, jsMomentDatetimeFormat) }}
            </span>
        </v-server-table>
    </div>
    
    
    
    data() {
        return {
            activityLogs: [],
    
            el: "#activity_logs_data_table",
            columns: ['id', 'log_name', 'causer_id', 'causer_type', 'created_at', 'edit'],
    
            tableOptions: {
                requestFunction: (data) => {
                    console.log('requestFunction data::')
                    console.log(data)
    
                    this.is_page_loaded = false
                    this.credentialsConfig.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken;
                    console.log('requestFunction this.credentialsConfig::')
                    console.log(this.credentialsConfig)
    
                    return axios.get(this.url, {
                        params: data
                    }, this.credentialsConfig ).catch(function (error) {
                        console.log('requestFunction error::')
                        console.error(error)
                        // this.dispatch('error', error );
                    });
    
                } // requestFunction: (data) => {

But I see error in console :

    TypeError: Cannot read property 'indexOf' of undefined
        at buildURL (buildURL.js?30b5:62)
        at dispatchXhrRequest (xhr.js?b50d:30)
        at new Promise (<anonymous>)
        at xhrAdapter (xhr.js?b50d:12)
        at dispatchRequest (dispatchRequest.js?5270:52)

and printscreen of console with debugging : https://prnt.sc/rtak15 I see query parameter empty ... Could it be the issue? Are parameters in axios.get invalid ?

    "axios": "^0.19.0",
    "vue": "^2.6.10",
    "vue-tables-2": "^2.0.14" 

Thanks!

Apr
07
4 months ago
Activity icon

Started a new Conversation Search Laravel 6/7 Crud Generator With Blade, Jquery

Hello, Could you please advice some laravel 6/7 crud generator with blade, Jquery free and convinient in work? I found this https://github.com/appzcoder/crud-generator But I am not sure is it good for laravel 6/7 ?

Thank!

Mar
30
4 months ago
Activity icon

Replied to What Can Be Used For Vue/cli Frontend / Laravel 6 Backend REST API Testing

Thanks! Interesting. I started viewing it : looks like it more for laravel with blade. Are there some tutorial for @vue/cli 3 app / Laravel 6 Backend REST API ?

Mar
29
4 months ago
Activity icon

Replied to How To Keep Access_token Parameter From Login For Next Post Requests

Is it possible what I want ? If yes, how ?

Mar
27
4 months ago
Activity icon

Started a new Conversation What Can Be Used For Vue/cli Frontend / Laravel 6 Backend REST API Testing

I have expierence of using laravel dusk for testing laravel 5 app with using of vuejs 2 components Now I make @vue/cli 4.0.5 / vuex 3 app with data reading from Laravel 6 Backend REST API and wonder how both parts of the app can be tested?

Can laravel dusk be used for this or there are some better tools for this ?

Thanks!

Mar
26
4 months ago
Activity icon

Replied to Using WhenLoaded In Resource Collection I Got Error

Thanks for the feedback, Reading the docs I missed difference between "when"and "whenLoaded"?

Also if I want to use $user object in Closure in its second argument, can I do like :

                'user' => $this->when('user', function ($user) {
                    return $user->name;
                }),

?

Activity icon

Started a new Conversation How To Keep Access_token Parameter From Login For Next Post Requests

Hello, In swagger With api 3 version I have login described as :

  /login:
    post:
      tags:
        - user login
      summary: User login

      responses:
        '200':
          description: Successful login
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserLogin'
        '400':
          description: Invalid login

      operationId: postLogin
      requestBody:
        description: Login user fields
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                email:
                  type: string
                  default: [email protected]
                password:
                  type: string
                  default: 111111
              required:
                - email
                - password

and if login is successfull amonth returned data I have access_token field.

With schema described as :

components:
  schemas:


    UserLogin:
      properties:
        access_token:
          type: string
        user:
          $ref: '#/components/schemas/UserLogin'
        token_type:
          type: string
        user_avatar_path:
          type: string
        usersGroups:
          type: array
        expires_in:
          type: integer

I need to use this access_token value for next post requests to get access to authorized pages.

How can I do this in swagger. Seems I can not copypaste access_token value from login requeest for my post requests, asthey do not access_token parameter ?

Thanks!

Mar
24
4 months ago
Activity icon

Started a new Conversation Using WhenLoaded In Resource Collection I Got Error

Hello, In laravel 6 app I have a Resource Collection, which works ok for me :

class UserSkillCollection extends ResourceCollection
{
    public static $wrap = 'user_skills';

    public function toArray($request)
    {

        return $this->collection->transform(function($userSkill){
            return [
                'id' => $userSkill->id,
                'user_id' => $userSkill->user_id,
                'user_name' => $userSkill->user_name,
                'skill_id' => $userSkill->skill_id,
                'skill_name' => $userSkill->skill_name,
                'rating' => $userSkill->rating,
                'created_at' => $userSkill->created_at,
            ];
        });

    }

except when some fields are defined, like user_name, I have keys with null values.

To get rid of them I tried to use whenLoaded, but with line :

                'user_id' => $this->whenLoaded('user_id'),

I got error :

"message": "Method Illuminate\Support\Collection::relationLoaded does not exist.",

Which way is valid ?

Thanks!

Mar
10
5 months ago
Activity icon

Started a new Conversation How In Swagger To Make Requests To Auth Protected Backend App

Hello, Making first steps in swagger I created with api 3 version several response to public routes of my laravel 6 backend api app.

Now I wander how can I make requests to part of my backend app which are auth protected like :

Route::group(['middleware' => 'auth:api', 'prefix' => 'personal', 'as' => 'personal.'], function ($router) {
    Route::resource('ad-saved-filters', 'Personal\AdSavedFiltersController');
    ...

Please, link, how can I do it

Thanks!

Feb
28
5 months ago
Activity icon

Replied to How Show Maintenance Page If Appache Of Backend Server Is Not Running?

Sorry, if I did not put my question clearly I know how to catch 503 error. I wonder how can I catch when appach of backend app is not running / backend server is not running

Feb
27
5 months ago
Activity icon

Started a new Conversation How Show Maintenance Page If Appache Of Backend Server Is Not Running?

Hello! In @vue/cli 4.1.1 app I found in cases if appache is not running on backend server I got errors in console, but I do not see any code and I wonder if there is a way to catch it, something like 503 error of maintenance stopped?

Also say if backend server is not running at this time...

Thanks!

Activity icon

Replied to Valid Format Of Ranges For Vue2-daterange-picker

Thanks, that was helpfull. Now I have prior/next month icons at the corners of the calendar. Are there prior/next year icons available ?

Feb
26
5 months ago
Activity icon

Started a new Conversation Valid Format Of Ranges For Vue2-daterange-picker

Using vue2-daterange-picker I search how to hide left selection items, as 'Today','Yesterday', 'This month', 'This year', but I did find valid format. The thing is that now date picker looks like : https://prnt.sc/r8bbjt and I dislike those items which I prerfer to remove.

In the docs I found :

default ranges object (set to false to hide ranges)
{
    'Today',
    'Yesterday',
    'This month',
    'This year',
    'Last week',
    'Last month',
}

making :

                            <date-range-picker
                                    :opens="date_range_picker_locale_opens"
                                    @update="updateValues"
                                    :singleDatePicker="true"
                                    :locale-data="dateRangePickerLocale"
                                    :autoApply="true"
                                    :ranges="defaultRanges"
                                    :show-dropdowns="false"
                                    :alwaysShowCalendars="false"
                                    v-model="ad_expire_date"
                                    class="form-control editable_field"
                            >
                                <div slot="input" slot-scope="picker">
                                    {{ picker.startDate | date }}
                                </div>
                            </date-range-picker>

but it did not help

...
                defaultRanges: {  // I got a eslint syntax errors
                    'Today',
                    'Yesterday',
                    'This month',
                    'This year',
                    'Last week',
                    'Last month',
                },

Which is valid format?

    "vue": "^2.6.11",
    "vue2-daterange-picker": "^0.4.4",

Thanks!

Feb
24
5 months ago
Activity icon

Replied to How In Bootstrap-vue Convert FileReader To Blob And Upload To Server?

I still search for decision. Have anybody such uploading ?

Feb
19
5 months ago
Activity icon

Replied to How In Bootstrap-vue Convert FileReader To Blob And Upload To Server?

Very strange post above/ Sorry, was my question unclear ? I need to convert uploading image to blob...

Activity icon

Started a new Conversation How In Bootstrap-vue Convert FileReader To Blob And Upload To Server?

Hello, In @vue/cli 4.1.1 app I use bootstrap-vue and b-form-file conponent for images uploading

https://bootstrap-vue.js.org/docs/components/form-file/#multiple-files

with definition :

                <b-form-file
                    id="upload_ad_image"
                    v-model="new_upload_ad_image"
                    :state="Boolean(new_upload_ad_image)"
                    placeholder="Choose a file or drop it here..."
                    drop-placeholder="Drop file here..."
                    accept="image/jpeg, image/png, image/gif"
                ></b-form-file>
                
                <div ref="uploaded_img_preview" id="uploaded_img_preview" class="m-2" >Uploaded image preview :</div>

I found snippet https://codepen.io/Tenderfeel/pen/rgqWXR and using it I show selected file on my form for preview. Next I need to upload it on the server. I have an expierence of uploading image as blog using code like :

                fetch(this.taskRow.imageFile.blob).then(function (response) {
                    if (response.ok) {
                        return response.blob().then(function (imageBlob) {
                            let imageUploadData = new FormData()
                            imageUploadData.append('id', self.taskRow.id)
                            imageUploadData.append('image', imageBlob)
                            imageUploadData.append('image_filename', self.taskRow.imageFile.name)

But I need to convert uploading image to blob. I use method when image is selected: But got error :

Error in callback for watcher "new_upload_ad_image": "InvalidStateError: Failed to execute 'readAsDataURL' on 'FileReader': The object is already busy reading Blobs               
        watch: {
            new_upload_ad_image(val) {
                if (!val) return;
                if (this.previewImg) {
                    this.previewImg.remove();
                }
                const img = document.createElement("img");
                img.classList.add("obj");
                img.file = this.new_upload_ad_image;
                console.log('img.file::')
                console.log(img.file)

                this.previewImg = img;
                console.log('this.$refs.uploaded_img_preview::')
                console.log(this.$refs.uploaded_img_preview)

                console.log('img::')
                console.log(img)

                this.$refs.uploaded_img_preview.appendChild(img);

                const fileReader = new FileReader();
                fileReader.onload = (e) => {
                    this.previewImg.src = e.target.result;
                };
                fileReader.readAsDataURL(this.new_upload_ad_image);
                console.log('fileReader::')
                console.log(fileReader)

                let blobObj= fileReader.readAsDataURL(img.file) // RAISE ERROR :

                console.log('blobObj::')
                console.log(blobObj)

            }
        },

What I see in the console : https://imgur.com/a/2EZxq9C

How to get blob and upload it on server?

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

Thanks!

Feb
15
6 months ago
Activity icon

Replied to Unexpected Response From Swagger

I found a hint that it could be cors related issue. I have installed :

        "barryvdh/laravel-cors": "^0.11.4",
        "laravel/framework": "^6.0",
With params in config/cors.php :
    'supportsCredentials' => true,
    'allowedOrigins' => [env('ALLOWED_ORIGINS')],
    'allowedOriginsPatterns' => [],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['*'],
    'exposedHeaders' => [],
    'maxAge' => 0,

and ref in ALLOWED_ORIGINS to my client vue/cli app. But how to make it permittable for swagger ?

Activity icon

Started a new Conversation Unexpected Response From Swagger

Hello, I make first steps in swagger and creating new app (api 3 version) I try to write requests to my laravel backend api and testing I do not see response I expect. I have definitions:

openapi: 3.0.0
info:
  description: A Simple IP Address API
  title: VTasks
  version: v1
servers:
# Added by API Auto Mocking Plugin
  - description: SwaggerHub API Auto Mocking
    url: https://virtserver.swaggerhub.com/petrogromovo/Vtasks/1.0.0
  - description: SwaggerHub API Auto Mocking
    url: http://vtasks.my-demo-apps.tk
#  host: vtasks.my-demo-apps.tk
# schemes:
#  - http
# basePath: /


paths:
  /:
    get:
      summary: Get client IP
      responses:
        '200':
          description: Success response
          
  /public_profile:
    get:
      tags:
        - user
      summary: Get public user info by id
      operationId: public_profile
      parameters:
        - name: user_id
          in: path
          description: The user_id that needs to be fetched. Use 1 for testing.
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: successful operation
        '400':
          description: Invalid username supplied
        '404':
          description: User not found

It shows syntax ok but trying to test how it works I enter user_id parameter, valid value and unvalid value of not existing user with such user_id, like : https://prnt.sc/r2rxgr I expected something like in postman, when I see if some data were found be request. Swagger works differently ?

Thanks!