mstdmstd

Member Since 4 Years Ago

Experience Points
22,200
Total
Experience

2,800 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
4
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.

  • Community Pillar

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

Level 5
22,200 XP
May
06
2 days ago
Activity icon

Replied to How In Laravel 8 With Tailwind CSS Define Backend.css Which Overwrite App.css?

  1. Different colors that is only one option. Diffence can be not only in color. 2) I do not see how different colkors must be defined for different css files. Please give example
Activity icon

Replied to How In Laravel 8 With Tailwind CSS Define Backend.css Which Overwrite App.css?

I tried to set app.css at top of resources/css/backend.css :

/* I TRIED TO UNCOMMENT BOTH LINES BELOW */
@import '/resources/css/app.css';
/*@import app.css;*/

@tailwind base;
@tailwind components;
@tailwind utilities;


@layer base {

    .test_class {
        @apply text-gray-300 bg-red-800;
    }


    /*.app_main_color {*/
    /*    @apply text-gray-300 bg-green-900;*/
    /*}*/



    .admin_page_container_wrapper {
        @apply flex-1 p-0 m-0 app_main_color;
    }

Biut any way I got SyntaxError :

(26:31) /mnt/_work_sdb8/wwwroot/lar/tAdsBack/resources/css/backend.css The `app_main_color` class does not exist. If you're sure that `app_main_color` exists, make sure that any `@import` statements are being properly processed before Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.

  24 | 
  25 |     .admin_page_container_wrapper {
> 26 |         @apply flex-1 p-0 m-0 app_main_color;
     |                               ^
  27 |     }
  28 | 

...

Activity icon

Started a new Conversation How In Laravel 8 With Tailwind CSS Define Backend.css Which Overwrite App.css?

In a Laravel 8 / Tailwind CSS v2.1 application, I make different layouts. So in `webpack.mix.js, I have custom class files defined:

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

    const tailwindcss = require('tailwindcss');


    mix.js('resources/js/app.js', 'public/js')
        .postCss('resources/css/app.css', 'public/css', [
            require("tailwindcss"),
        ])
        .postCss('resources/css/backend.css', 'public/css', [
            require("tailwindcss"),
        ])
        .postCss('resources/css/profile.css', 'public/css', [
            require("tailwindcss"),
        ])
        .options({
            processCssUrls: false,
            postCss: [tailwindcss('./tailwind.config.js')],
        });

backend.css and profile.css files have unique classes, but they all have some common classes in app.css. I want to define some common classes in app.css and possibility say in backend.css to overwrite :

    .admin_main_color {
        @apply text-gray-300 bg-green-900;
    }

which was priorly defined in common

In resources/views/layouts/backend.blade.php I added app.css (which is before of backend.css) :

    <title id="app_title">{{ config('app.name', 'Laravel') }}</title>

    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{ asset('css/backend.css') }}" rel="stylesheet">

In resources/css/app.css I have :

    @tailwind base;
    @tailwind components;
    @tailwind utilities;

    @layer base {

        .app_main_color { // in some cases I need to possibility to overwrite class in frontend.css/backend.css
            @apply text-yellow-300 bg-red-900;
        }

But when I try in resources/css/backend.css :

    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    @import app.css;


    @layer base {

        .test_class {
            @apply text-gray-300 bg-red-800;
        }

        /*.app_main_color {*/
        /*    @apply text-gray-300 bg-green-900;*/
        /*}*/

If to leave commented 3 lines above, I got error in the console :

     (23:31) /mnt/_work_sdb8/wwwroot/lar/tAdsBack/resources/css/backend.css The `app_main_color` class does not exist. If you're sure that `app_main_color` exists, make sure that any `@import` statements are being properly processed before Tailwind CSS sees your CSS, as `@apply` can only be used for classes in the same CSS tree.

Lines with :

    @import app.css;

did not help. How can I do it? I hope I clearly explained what I want...

And that will overwrite the admin_main_color definition in app.css. Can I do this, and how?

Thanks!

May
03
5 days ago
Activity icon

Started a new Conversation How To Work In Laravel With Uuid Fields For ID Of Tables?

Hello, Supporting laravel 6 app I found tables with uuid fields for ID of tables, like :

 Schema::create('users', function (Blueprint $table) {
            $table->uuid('id');

        Schema::create('itemss', function (Blueprint $table) {
            $table->uuid('id');
            $table->uuid('user_id');

in this app no foreign keys were defined, so I wonder are restrictions that for uuid fields and are there some difference when using uuid fields and common fields created with $table->increments ?

Thanks!

May
01
1 week ago
Activity icon

Started a new Conversation I Got Error Using Api.currencylayer.com Service

Hi, our site laravel 5.8 which use api.currencylayer.com stopped to work and I see error in console of my browser : https://prnt.sc/12d06pw

also when run url in browser I got error : https://prnt.sc/12d08az

our account is active and not expired : https://prnt.sc/12d09ln

I wrote to support of api.currencylayer.com 3 days ago and still did not got any feedback

Does somebody know what is wrong and why error? This request worked ok about a week ago and now this error. I checked in bitbucket : there were no any code modifications which could ocasionally break the app.

  1. I tried to fix it by registering at api.currencylayer.com site and created free plan and set new registered access key into the app and still have the same errors

Thanks!

Apr
30
1 week ago
Activity icon

Replied to Why Axios Request /sanctum/csrf-cookie In Vuejs To Laravel Sanctum Returns 204 No Content?

If I try to make login request afer I got 204 in responce of /sanctum/csrf-cookie I got next 419 error in client code :

    login() {
      axios.get('/sanctum/csrf-cookie').then(response => {
        console.log('response:::')
        console.log(response)
        axios.post('/login', {
          email: this.email,
          password: this.password,
        }).then(response2 => {
          console.log('response2:::')
          console.log(response2);
          ...
        }).catch(error => {
          console.log(error);
        })
      })
    }

I suppose because of csrf was not set in my app https://prnt.sc/127b8pl Have I to set it manually somehow or some missing packages? package.json of my app :

{
  "name": "vsanc",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "core-js": "^3.6.5",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

Opening one of my Laravel 8 app I see cookies are set : https://prnt.sc/12aarn0

Why I have no csrf applied in cookie ?

Apr
28
1 week ago
Activity icon

Replied to Why Axios Request /sanctum/csrf-cookie In Vuejs To Laravel Sanctum Returns 204 No Content?

I added option

axios.get('/sanctum/csrf-cookie',  { withCredentials: true }).then(response => {

After I got 204 code I see Set-Cookie Responce headers. But checking cookies of my browsers I see it empty : https://prnt.sc/127b8pl In settings of my browser : https://prnt.sc/127bbgs also if this way is good if it is dependable on cookies set on clients browser ?

Activity icon

Replied to Why Axios Request /sanctum/csrf-cookie In Vuejs To Laravel Sanctum Returns 204 No Content?

Is it mentioned somehwere in docs https://laravel.com/docs/8.x/sanctum ? 204 response seems no sense as I need to get code and keep it on client side ? What I see in my browser : prnt.sc/126mtsm and details prnt.sc/126n0p5: Is it correct response ?

Activity icon

Replied to Why Axios Request /sanctum/csrf-cookie In Vuejs To Laravel Sanctum Returns 204 No Content?

Searching how to fix the issue I payed attention that : 1)I did not find file app/Providers/SanctumServiceProvider.php, even I run command

Project$ php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
Copied Directory [/vendor/laravel/sanctum/database/migrations] To [/database/migrations]
Publishing complete.

So I manually copied file from vendor/laravel/sanctum/src/SanctumServiceProvider.php

into app/Providers/SanctumServiceProvider.php and it has content :

<?php

namespace Laravel\Sanctum;

use Illuminate\Auth\RequestGuard;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Sanctum\Http\Controllers\CsrfCookieController;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;

class SanctumServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        config([
            'auth.guards.sanctum' => array_merge([
                'driver' => 'sanctum',
                'provider' => null,
            ], config('auth.guards.sanctum', [])),
        ]);

        if (! $this->app->configurationIsCached()) {
            $this->mergeConfigFrom(__DIR__.'/../config/sanctum.php', 'sanctum');
        }
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->registerMigrations();

            $this->publishes([
                __DIR__.'/../database/migrations' => database_path('migrations'),
            ], 'sanctum-migrations');

            $this->publishes([
                __DIR__.'/../config/sanctum.php' => config_path('sanctum.php'),
            ], 'sanctum-config');
        }

        $this->defineRoutes();
        $this->configureGuard();
        $this->configureMiddleware();
    }

    /**
     * Register Sanctum's migration files.
     *
     * @return void
     */
    protected function registerMigrations()
    {
        if (Sanctum::shouldRunMigrations()) {
            return $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
        }
    }

    /**
     * Define the Sanctum routes.
     *
     * @return void
     */
    protected function defineRoutes()
    {
        if ($this->app->routesAreCached() || config('sanctum.routes') === false) {
            return;
        }

        Route::group(['prefix' => config('sanctum.prefix', 'sanctum')], function () {
            Route::get(
                '/csrf-cookie',
                CsrfCookieController::class.'@show'
            )->middleware('web');
        });
    }

    /**
     * Configure the Sanctum authentication guard.
     *
     * @return void
     */
    protected function configureGuard()
    {
        Auth::resolved(function ($auth) {
            $auth->extend('sanctum', function ($app, $name, array $config) use ($auth) {
                return tap($this->createGuard($auth, $config), function ($guard) {
                    app()->refresh('request', $guard, 'setRequest');
                });
            });
        });
    }

    /**
     * Register the guard.
     *
     * @param \Illuminate\Contracts\Auth\Factory  $auth
     * @param array $config
     * @return RequestGuard
     */
    protected function createGuard($auth, $config)
    {
        return new RequestGuard(
            new Guard($auth, config('sanctum.expiration'), $config['provider']),
            $this->app['request'],
            $auth->createUserProvider($config['provider'] ?? null)
        );
    }

    /**
     * Configure the Sanctum middleware and priority.
     *
     * @return void
     */
    protected function configureMiddleware()
    {
        $kernel = $this->app->make(Kernel::class);

        $kernel->prependToMiddlewarePriority(EnsureFrontendRequestsAreStateful::class);
    }
}

I see at method defineRoutes whioch has defined :

            Route::get(
                '/csrf-cookie',
                CsrfCookieController::class.'@show'
            )->middleware('web');

So I try to debug this method with logging, like :

class CsrfCookieController
{
    /**
     * Return an empty response simply to trigger the storage of the CSRF cookie in the browser.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function show(Request $request)
    {
        \Log::info( '-1 show.CsrfCookieController ::' . print_r( -1, true  ) );

        if ($request->expectsJson()) {
            \Log::info( '-2 show.CsrfCookieController ::' . print_r( -2, true  ) );
            return new JsonResponse(null, 204);
        }
        \Log::info( '-3 show.CsrfCookieController ::' . print_r( -3, true  ) );

        return new Response('', 204);
    }

and in file laravel.log I see output of “-1” and “-2” lines.

Also my responce output has lines :

Request URL: http://local-vsanc-backend-api.com/sanctum/csrf-cookie
Request Method: GET
Status Code: 204 No Content
Remote Address: 127.0.0.25:80
Referrer Policy: strict-origin-when-cross-origin

http://local-vsanc-backend-api.com - is host of my backend app which is writen in file /etc/hosts(on my local kubuntu 18) as :

127.0.0.1	localhost
127.0.1.1	AtHome

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
...
127.0.0.25      local-vsanc-backend-api.com

I suppose that my both apps frontend are on the same domain...

Can it be the issue ?

Apr
27
1 week ago
Activity icon

Started a new Conversation Why Axios Request /sanctum/csrf-cookie In Vuejs To Laravel Sanctum Returns 204 No Content?

Hello, I try to use laravel 8 Sanctum in my vuejs 2 Spa app and I created 2 app. But running request from SPA page :

      axios.get('/sanctum/csrf-cookie').then(response => {
        console.log('response::')
        console.log(response)
    
      })

I got returned:

status: 204, statusText: "No Content"

I followed some articles like : https://blog.codecourse.com/setting-up-laravel-sanctum-airlock-for-spa-authentication-with-vue/

and seems I followed in backend app, as :

In .env I added/modified lines :

SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost

SESSION_DRIVER=cookie

i run client on http://localhost:8080/ host

In /routes/api.php I modified :

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

In config/cors.php :

    'paths' => [
        'api/*',
        '/login',
        '/logout',
        'sanctum/csrf-cookie'
    ],

    'supports_credentials' => true,

In config/sanctum.php :

    'stateful' => explode(',', env(
        'SANCTUM_STATEFUL_DOMAINS',
        'localhost:8080,localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1,'.parse_url(env('APP_URL'), PHP_URL_HOST)
    )),
...
    'middleware' => [
        'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
        'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
    ],

I modified app/Http/Kernel.php :

    protected $middlewareGroups = [
        'api' => [
            \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
            'throttle:api',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],


    ];

Seacrhing in net for decisons I found several branches with decision,like https://stackoverflow.com/questions/62733796/spa-vue-frontend-and-laravel-7-backend-sanctum

I tried to modify file app/Providers/RouteServiceProvider.php, but originally it was different as mentioned in the branch above :

<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * The path to the "home" route for your application.
     *
     * This is used by Laravel authentication to redirect users after login.
     *
     * @var string
     */
    public const HOME = '/home';

    /**
     * The controller namespace for the application.
     *
     * When present, controller route declarations will automatically be prefixed with this namespace.
     *
     * @var string|null
     */
    // protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        $this->configureRateLimiting();

        $this->routes(function () {
            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });
    }

    /**
     * Configure the rate limiters for the application.
     *
     * @return void
     */
    protected function configureRateLimiting()
    {
        RateLimiter::for('api', function (Request $request) {
            return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
        });
    }
}

So it does not have mapApiRoutes method and I tried in 2 way :

    public function boot()
    {
        $this->configureRateLimiting();

        $this->routes(function () {
/*            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('routes/api.php'));*/

            Route::prefix('api')
                 ->middleware('web')
                 ->namespace($this->namespace)
                 ->group(base_path('routes/api.php'));

            Route::middleware('web')
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));
        });
    }

// Or added mapApiRoutes function
    protected function mapApiRoutes() 
    {
        Route::prefix('api')
             ->middleware('web')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

But It did not help and I still got 204 error.\

What is wrong ?

In my composer.json :

    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.12",
        "laravel/sanctum": "^2.10",
        "laravel/tinker": "^2.5",
        "laravel/ui": "^2.0"
    },

Thanks!

Activity icon

Replied to How To Make In Laravcel With Mailchimp Some Functionality ?

Could you please to point to MailChimp API you mentioned? I worked with wrapper libraries before...

Activity icon

Started a new Conversation How To Make In Laravcel With Mailchimp Some Functionality ?

Hello, In laravel 8 app ads app I added mailchimp support using https://github.com/drewm/mailchimp-api with functionality when any ads category of my app can be assigned revoked to mailchimp list group. Also any user in the system can be assigned to subscription of amy category/list

Next I need dayly create a report which new ads were create and send report to users of related category. I can run cron task and to create new ads listing, but how can it be send to mailchimp .

Also my app has small CMS subsystem, based on tinyMCE text. Can I save my pages and send them to mailchimp as template for my subscription email?

Looks like drewm/mailchimp-api has no such functionality?

How can I make it?

Thanks!

Apr
21
2 weeks ago
Activity icon

Replied to How In Export With Maatwebsite Excel Add Data From Related Table?

I try to read file content and keep it serialized in model attribute as :

                $adImages = AdImage
                    ::getByAdId($adItem->id)
                    ->get();
                foreach( $adImages as $next_key=>$nextAdImage ) {
                
                    $nextAdImageImgProps = AdImage::readAdImageProps($nextAdImage->ad_id, $nextAdImage->image, true);
                        $imagePath= storage_path() . '/app/public/' . $nextAdImageImgProps['image_path'];
                        $imageContent =   file($imagePath);
                        $adImages[$next_key]->setImageContentAttribute( serialize($imageContent) );
                    }


                }
                \Log::info(  varDump($adImages, ' -1 $adImages::') );

But looking at resulting $adImages I see that its rows has no imageContent field, which I defined in in app/Models/AdImage.php :

class AdImage extends Model
{

    protected $fillable = [ 'ad_id', 'image', 'main', 'info', 'imageContent'];

    protected $table = 'ad_images';
    protected $primaryKey = 'id';
    public $timestamps = false;

    protected $imageContent = '';

    protected $image_filename_max_length = 100;
//    protected $appends = ['imageContent']; // If to uncomment this line - the same result
    protected $attributes = array(
//        'imageContent' => '',   // If to uncomment this line - the same result
    );

    ...

    public function setImageContentAttribute($imageContent)
    {
        \Log::info(  varDump($imageContent, ' -1 setImageContentAttribute $imageContent::') );
         $this->imageContent= $imageContent;
    }

    public function getImageContentAttribute()
    {
        return $this->imageContent;
    }

Checking logs I see that method setImageContentAttribute is called with valid parameter ...

Did I define imageContent attribute in wrong way?

Apr
19
2 weeks ago
Activity icon

Replied to How In Export With Maatwebsite Excel Add Data From Related Table?

Thanks! With Using custom structures I got some packed array in excel cell? Could you please point 1) to methods I need to import these data into my db in several joined tables? 2) If there is a way to export/import image in this way?

Activity icon

Started a new Conversation How In Export With Maatwebsite Excel Add Data From Related Table?

In Laravel 8 with "maatwebsite/excel": "^3.1" I make export of table row with features that some enum columns must have label instead of enum values like :

public function collection()
{
    $adsIdList = [7,1,5];
    return Ad
        ::getById($adsIdList)
        ->get()
        ->map(function ($adItem)  {
            $a = Carbon::createFromFormat('Y-m-d', $adItem->expire_date);
            $is_past = $a->isPast();
            $retAdItem = [
                'id'     => $adItem->id,                                // A
                'title'     => $adItem->title,                          // B
                'slug'    => $adItem->slug,                             // C
                'phone_display' => $adItem->phone_display ? 'Y' : 'N',  // D
                'has_locations' => $adItem->has_locations  ? 'Y' : 'N', // E
                'status' => Ad::getStatusLabel($adItem->status),        // F
                'price' => $adItem->price,                              // G
                'ad_type' => Ad::getAdTypeLabel($adItem->ad_type),      // H
                'expire_date' => $adItem->expire_date,                  // I
                'is_past' => $is_past,                                  // ?

also I add some calculative fields in my app/Exports/AdsExport.php file above.

But if there is a way to add data from related table? Any Ad can have several ad_locations with several fields... Later I will need to write import functionality to generated in export files...

Thanks!

Apr
12
3 weeks ago
Activity icon

Started a new Conversation How To Return Data From Component Method With Axios Request ?

Hello, In laravel 8 / AlpineJs 2.8 I project I created component with command

php artisan make:component  Admin/UsersAccess

and I have 2 files : app/View/Components/Admin/UsersAccess.php where in render method I define which view I use :

    public function render()
    {

        $permissionsArray= Permission
            ::select('*')
            ->get()
            ->pluck('name', 'id')->toArray();
        ...
        return view('components.admin.users-access', compact('usersArray', 'permissionsArray'));
    }

and I need to use axios requests and I put methods I need in controller with routes defined :

Route::resource('users/{permission_id}/users_access', UserAccessController::class);

and reading data in JS block as :

                    window.axios.get('/admin/users/' + filter_permission + '/users_access').then((response) => {
                        console.log('filterPermissionClicked response::')
                        console.log(response)
                        this.users = response.data.users
                    }).catch((error) => {
                        console.error(error)
                        // popupErrorMessage(error.response.data.message)
                    })

It works ok, but I want to move methods from controller to my Admin/UsersAccess component. I modified in routes/web.php and set UsersAccess to routes:

use App\View\Components\Admin\UsersAccess;
...

    Route::resource('users/{permission_id}/users_access', UsersAccess::class);//->name('users_access.permission');

I see that data are read ok, but returned data have somewhat strange format and I can not assign them to my js array : https://imgur.com/a/e7Q6cgV. So listing of data I make based on this.users is empty. Why any elemen has Proxy type and hoq to unwrap it ?

Thanks!

Apr
07
1 month ago
Activity icon

Started a new Conversation How Get Object Of Dropped Item In Drag-and-drop Example?

Hello, With AlpineJs 2.8 I remake drag-and-drop example from https://codepen.io/trovster/pen/oNjGGMq

based on dynamic data and when item dropped I need to get item ID of any element, I try to make it parsing event on drop event. Looking into console https://prnt.sc/115ikf5 I see event.srcElement, but it is strin, not object, from which I want to get ID:

        toListingDropped: function (event) {
            console.log('toListingDropped event::')
            console.log(event)

            console.log('toListingDropped event.srcElement::')
            console.log(event.srcElement) // I expect this link to dragable item - but I see html code, not object
            console.log('toListingDropped event.srcElement.id::')
            console.log(event.srcElement.id) // I need to get thuis ID

Pen link : https://codepen.io/sergeynilov/pen/zYNobRP

How to get object of dropped item ?

Thanks!

Apr
04
1 month ago
Activity icon

Started a new Conversation How To Impement Tooltip In Fullcalendar With Alpinejs?

I added fullcalendar v4.3.1 to Laravel 8 / tailwindcss 2 / Alpinejs 2.8 app and it works, but I encountered a question how to impement tooltips with keeping mouve over date cell? With jquery support I made with tooltip libarary :

events: function(info, successCallback, failureCallback) {    
    $(eventInfo.el).tooltip({
        title: adHtml,
        html: true,
    })

I found example with tailwindcss tooltip impementation when button is on the foem : https://codepen.io/t7team/pen/XWdyVyB

But with fullcalendar it seems tricky...

How it cab be done ?

Thanks!

Mar
31
1 month ago
Activity icon

Started a new Conversation How To Fix Error Setting Key Event On Form By Its ID?

Hello,

I want to add google map into my Laravel 8 / tailwindcss 2 / Alpinejs 2.8 app and I found example https://laraveldaily.com/laravel-find-addresses-with-coordinates-via-google-maps-api/

As I do not use jquery, but alpinejs I got an error :

alpine.js:115 Alpine Error: "TypeError: form_ad_location_edit.on is not a function"

When I try to remake code :

    $('form').on('keyup keypress', function(e) {
        var keyCode = e.keyCode || e.which;
        if (keyCode === 13) {
            e.preventDefault();
            return false;
        }
    });

into :

    <form action="{{ route('admin.ads.ad_locations.'. ( $isInsert ? 'store' : 'update'), [1, ( $adLocation->id ?? '' ), 1 ] ) }}" method="POST" id="form_ad_location_edit" enctype="multipart/form-data">

    let form_ad_location_edit = document.querySelector("#form_ad_location_edit")
    console.log('form_ad_location_edit::')
    console.log(form_ad_location_edit)

    form_ad_location_edit.on('keyup keypress', function(e) {
        var keyCode = e.keyCode || e.which;
        if (keyCode === 13) {
            e.preventDefault();
            return false;
        }
    });

In the console I see that I got valid form elememt ?

Which way is valid ?

Thanks!

Mar
25
1 month ago
Activity icon

Started a new Conversation I Got Stripe \ PermissionException Error With New Stripe Api Keys

Hello, Working with Stripe Connect in laravel 5.8 app and making :

\Stripe\Charge::create

I got error :

Stripe \ Exception \ PermissionException
The provided key 'sk_test_51*********************************************************************************************AE7z' does not have access to account 'acct_NNNN' (or that account does not exist). Application access may have been revoke

My code worked with different stripe account, but I need to set api keys of my client After logtin into stripe with credentials of my client I just activated the the Stripe connect, but looks like not all settings are set: https://prnt.sc/10vfict

  1. Which steps have I to take next ?

  2. I wrote to support under my client credentials, but my client not alwaysa available and as I have no acccess to his email account I ask if there is a way to read messages from support in stripe dashboard? I did not find such possibility...

Thanks!

Mar
22
1 month ago
Activity icon

Replied to With StripeClient I Got Error No API Key Provided

Thanks! I made next step. Also could you please give a hint or link to a flow of similar decision as In my app registered users (customers )get help from other registered users (consultants) and they both pay to company(the owner of stripe account).

Also Company pays to consultants in cases they consulted customers. I try to find out valid flow, but it is still vague,,,

Activity icon

Replied to With StripeClient I Got Error No API Key Provided

I have line with logging app.STRIPE_TEST_KEY

if ($appEnv == 'local' or $appEnv == 'dev') {
	\Log::info('-1 config(app.STRIPE_TEST_KEY)::' . print_r(config('app.STRIPE_TEST_KEY'), true));

and checking log file I see valid sk_test_NNN value in log line, but not inside of coreServiceFactory:Stripe\StripeClient object(I show it in my topic)

Activity icon

Started a new Conversation With StripeClient I Got Error No API Key Provided

Hello,

in my Laravel 8 / with stripe/stripe-php": "^7.75" I try to connect and create account on stripe side and got error : No API key provided. Set your API key when constructing the StripeClient instance, or provide it on a per-request basis using the api_key key in the $opts argument.

with code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Session;
use Stripe;
use Stripe\StripeClient;
use App\Http\Controllers\Controller;
use Illuminate\Database\DatabaseManager;

use App\Models\Settings;
use Carbon\Carbon;
use Illuminate\Support\Arr;
use App\Models\User;
use App\Models\StripeToken;

class SellerController extends Controller
{
	protected StripeClient $stripeClient;
	protected DatabaseManager $databaseManager;
	public function __construct(StripeClient $stripeClient, DatabaseManager $databaseManager)
	{

		\Log::info(varDump($stripeClient, ' -1 SellerController ::'));
		$this->stripeClient = $stripeClient;
		$this->databaseManager = $databaseManager;
	}

	public function showProfile($id)
	{
		\Log::info('-1 showProfile $id ::' . print_r($id, true));
		$seller = User::find($id);
		if (!$seller) {
			abort(404);
		}
		return view('market.seller', [
			'seller' => $seller,
			'balance' => null
		]); // /_wwwroot/lar/tAdsBack/resources/views/admin/stripe/stripe.blade.php

	} // public function showProfile($id)

	public function redirectToStripe($id)
	{
		\Log::info('-1 redirectToStripe $id ::' . print_r($id, true));
		$seller = User::find($id);
		if (!$seller) {
			abort(404);
		}
		$appEnv = strtolower(config('app.env'));

		if ($appEnv == 'local' or $appEnv == 'dev') {
			\Log::info('-1 config(app.STRIPE_TEST_KEY)::' . print_r(config('app.STRIPE_TEST_KEY'), true));
			\Stripe\Stripe::setApiKey(config('app.STRIPE_TEST_KEY')); // LOOKS LIKE THAT IS NOT APPLIED
			$this->stripeClient->apiKey = config('app.STRIPE_TEST_KEY'); // THIS DOES NOT HELP
			$this->stripeClient->api_key = config('app.STRIPE_TEST_KEY');  // THIS DOES NOT HELP
		}
		if ($appEnv == 'production') {
			\Stripe\Stripe::setApiKey(config('app.STRIPE_LIVE_KEY'));
			$this->stripeClient->opts['api_key'] = config('app.STRIPE_LIVE_KEY');
		}


		if (!$seller->completed_stripe_onboarding) { // Complete onboarding process
			$str = \Str::random();
			$stripeToken = new StripeToken();
			$stripeToken->token =  $str;
			$stripeToken->seller_id =  $id;
			$stripeToken->save();


			if (empty($seller->stripe_connect_id)) {  // if has no stripe account
				// // Create a new Stripe Connect Account object.
				\Log::info('-1 $$this->stripeClient ::' . print_r($this->stripeClient, true));

Checking log I see :

[2021-03-22 05:40:30] local.INFO: -1 $$this->stripeClient ::Stripe\StripeClient Object
(
    [coreServiceFactory:Stripe\StripeClient:private] => 
    [config:Stripe\BaseStripeClient:private] => Array
        (
            [api_key] => 
            [client_id] => 
            [stripe_account] => 
            [stripe_version] => 
            [api_base] => https://api.stripe.com
            [connect_base] => https://connect.stripe.com
            [files_base] => https://files.stripe.com
        )

    [defaultOpts:Stripe\BaseStripeClient:private] => Stripe\Util\RequestOptions Object
        (
            [apiKey] => 
            [headers] => Array
                (
                    [Stripe-Account] => 
                    [Stripe-Version] => 
                )

            [apiBase] => 
        )

    [api_key] => sk_test_NNNNNN

How to fix this error ?

I suppose I need to set api_key in some other way, not

			$this->stripeClient->apiKey = config('app.STRIPE_TEST_KEY'); // THIS DOES NOT HELP
			$this->stripeClient->api_key = config('app.STRIPE_TEST_KEY');  // THIS DOES NOT HELP

but how?

Thanks!

Mar
21
1 month ago
Activity icon

Started a new Conversation Connecting To Stripe I Got Undefined Property: Stripe\Service\CoreServiceFactory::$account Error

in my Laravel 8 / with stripe/stripe-php": "^7.75" I try to connect and create account on stripe side and got error :

     Undefined property: Stripe\Service\CoreServiceFactory::$account

with code:

    <?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use Session;
    use Stripe;
    use Stripe\StripeClient;
    use App\Http\Controllers\Controller;
    use Illuminate\Database\DatabaseManager;
    
    use App\Models\Settings;
    use Carbon\Carbon;
    use Illuminate\Support\Arr;
    use App\Models\User;
    use App\Models\StripeToken;
    
    class SellerController extends Controller
    {
    	protected StripeClient $stripeClient;
    	protected DatabaseManager $databaseManager;
    	public function __construct(StripeClient $stripeClient, DatabaseManager $databaseManager)
    	{
    		$this->stripeClient = $stripeClient;
    		$this->databaseManager = $databaseManager;
    	}
    
    	public function redirectToStripe($id)
    	{
    		\Log::info('-1 redirectToStripe $id ::' . print_r($id, true));
    		$seller = User::find($id);
    		if (!$seller) {
    			abort(404);
    		}
    		$appEnv= strtolower(config('app.env'));
    
    		if ($appEnv == 'local' or $appEnv == 'dev') {
    		// In logs I see valid Test key assigned
    			\Log::info('-1 config(app.STRIPE_TEST_KEY)::' . print_r(config('app.STRIPE_TEST_KEY'), true));
    			\Stripe\Stripe::setApiKey(config('app.STRIPE_TEST_KEY')); 
    		}
            if( $appEnv == 'production' ) {
                \Stripe\Stripe::setApiKey( config('app.STRIPE_LIVE_KEY') );
            }
    
    
    		if (!$seller->completed_stripe_onboarding) {
    			$str = \Str::random();
    			$stripeToken = new StripeToken();
    			$stripeToken->token =  $str;
    			$stripeToken->seller_id =  $id;
    			$stripeToken->save();
    		}
    
    		if (!$seller->completed_stripe_onboarding) {
    			// Create a new Stripe Connect Account object.
    			\Log::info('-1 $$this->stripeClient ::' . print_r($this->stripeClient, true));
    			$account = $this->stripeClient->account->create(
    				[
    					'country' => 'US',
    					'type' => 'express',
    					'email' => $seller->email,
    				]
    			);

I check StripeClient object in log :

    [2021-03-21 15:26:18] local.INFO: -1 $$this->stripeClient ::Stripe\StripeClient Object
    (
        [coreServiceFactory:Stripe\StripeClient:private] => 
        [config:Stripe\BaseStripeClient:private] => Array
            (
                [api_key] => 
                [client_id] => 
                [stripe_account] => 
                [stripe_version] => 
                [api_base] => https://api.stripe.com
                [connect_base] => https://connect.stripe.com
                [files_base] => https://files.stripe.com
            )
    
        [defaultOpts:Stripe\BaseStripeClient:private] => Stripe\Util\RequestOptions Object
            (
                [apiKey] => 
                [headers] => Array
                    (
                        [Stripe-Account] => 
                        [Stripe-Version] => 
                    )
    
                [apiBase] => 
            )

How to fix this error ?

Thanks!

Mar
20
1 month ago
Activity icon

Started a new Conversation I Got Error Installing Chrome Support On Live Server

I try to install spatie/browsershot in laravel 5.8 app on live ubuntu 18 server and as I need to install Chrome support I try to run commands :


curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium

But I got error running first command :


[email protected]:~/www/laravel.servername.io$ who
servername pts/0        Mar 20 14:18 (NNN.NNN.NNN.NNN)
[email protected]:~/www/laravel.servername.io$ lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.5 LTS
4.15.0-121-generic
x86_64
[email protected]:~/www/laravel.servername.io$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
[sudo] password for servername: 
servername is not in the sudoers file.  This incident will be reported.
[email protected]:~/www/laravel.servername.io$ node -v
v14.15.4

Why error and how it can be fixed?

Thanks!

Mar
18
1 month ago
Activity icon

Started a new Conversation Which Stripe API Must Be Used When Customer Recieves Money From Owner Of Stripe Account ?

Hello, In laravel 5.8 app with stripe/stripe-php: ^7.50 when customer pays for provided services it has code:

            \Stripe\Stripe::setApiKey( config('app.STRIPE_TEST_KEY') );
            $user = User::where('id', $request->user_id)->first();
            $customer_id = $user->stripe_customer_id;

                    $charge = \Stripe\Charge::create([
                        'amount' => $request->amount * 100, // Say $request->amount= 50
                        'currency' => $request->currency,   // USD
                        'customer' => $customer_id
                    ]);
                    TransactionsTable::create([
                        'user_id' => $user->id,
                        'type' => $request->card['brand'],
                        'amount' => $request->amount,
                        'currency' => $request->currency,
                        'transaction_id' => $charge->id,
                        'status' => $charge->status
                    ]);

And USD 50 is subtracted from customer card and is added to the owner of stripe account (in dev app.STRIPE_TEST_KEY)

But if in case when customer recieves money from owner of stripe account (customer earned some maney on the site) which API can I to use? The same API/code( \Stripe\Charge::create) with negative sum or other api must be used ? I do not know can I call this operation as refund or other operation?

Thanks!

Mar
15
1 month ago
Activity icon

Replied to Why In Visualstudio By Double Clicking On The Variable $ Is Not Selected ?

Thanks for this link! Looks like with this rule variable is selected with : https://prnt.sc/10mc93s but when I want to copy this vraible and to paste in this editor first $ char : https://prnt.sc/10mcdhd Can it be some other rule for copy paste operations? If to paste this var in other editor - first $ char is lost too...

Mar
12
1 month ago
Activity icon

Started a new Conversation Why In Visualstudio By Double Clicking On The Variable $ Is Not Selected ?

Hello, I working with visualstudio 1.54.1 and I found that in blade.php file I want to copy some var by double clicking on the variable, like :

 {{ $amount }}
</div>
@endsection

<script>
	var amount = @json($amount);
	functionName()

literal of the var is selected, but not first $ char, that seems not good.

  1. Also clicking on functionName() function is not opened in accessible *.js file Can it be fixed somehow?

I have a lot of plugins installed ,like : Laravel Blade Snippets Laravel Blade Spacer Laravel Snippets Laravel Extra Intellisense PHP Intelephense Getter and Setter Generator Bracket Pair Colorizer JavaScript (ES6) code snippets

Some other plugins?

Thanks!

Mar
10
1 month ago
Activity icon

Replied to Why Code Visualstudio Shos Error At Line With \Log::inf ?

I am reading docs and actually found a lot of answers to my questions , but not all...

Activity icon

Replied to Why Code Visualstudio Shos Error At Line With \Log::inf ?

Thanks! That was helpfull ! Also could you, please, explain how can I :

  1. Create custom pieces of code and insert them into my page by code autocomplete ?
  2. Having some line of code as current by hotkeys to select more pieces of code into left and right sides?
  3. Having var or method like $some_long_name to convert it into $someLongName ?
Activity icon

Started a new Conversation Why Code Visualstudio Shos Error At Line With \Log::inf ?

Hello, I installedd code visualstudio 1.54.1 and installed main laravel plugins I found references, but I see that in a code:

    public function create()
    {
        $loggedUser = Auth::user();
        \Log::info(varDump(-1, ' -1 $::'));

Method \Log::info is marked with error as undefined.

Are there some additive options/plugins to salve it?

Thanks!

Mar
07
2 months ago
Activity icon

Replied to Why Template Literals In JS Code Do Not Work Anymore

It was my stuped error related with other issue. I did not find how to remove this post. Can I ?

Activity icon

Replied to Why Template Literals In JS Code Do Not Work Anymore

Searching for decision I found in yarn.lock lines :

  dependencies:
    consolidate "^0.15.1"
    hash-sum "^1.0.2"
    lru-cache "^4.1.2"
    merge-source-map "^1.1.0"
    postcss "^7.0.14"
    postcss-selector-parser "^6.0.2"
    source-map "~0.6.1"
    vue-template-es2015-compiler "^1.9.0"
  optionalDependencies:
    prettier "^1.18.2"

...
[email protected]^1.9.0:
  version "1.9.1"
  resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
  integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==

and in file package-lock.json a 101 references of “ES2015” like :

            "requires": {
                ... 
                "vue-template-es2015-compiler": "^1.9.0"
            },
...

                "babel-plugin-check-es2015-constants": {
                    "version": "6.22.0",
                    "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz",
                    "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=",
                    "requires": {
                        "babel-runtime": "^6.22.0"
                    }
                },
                "babel-plugin-transform-es2015-arrow-functions": {
                    "version": "6.22.0",
                    "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz",
                    "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=",
                    "requires": {
                        "babel-runtime": "^6.22.0"
                    }
                },

I see support of ES2015 in these file and wonder why template literals do not work now ?

Mar
05
2 months ago
Activity icon

Replied to Why Template Literals In JS Code Do Not Work Anymore

package.json has :

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.19.2",
        "bootstrap": "^4.1.0",
        "cross-env": "^5.1",
        "jquery": "^3.5.1",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.13",
        "popper.js": "^1.12",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.15.2",
        "sass-loader": "^7.1.0",
        "vue": "^2.5.17",
        "vue-template-compiler": "^2.6.11"
    },
    "dependencies": {
        "accordion-vue": "^1.0.1",
        "laravel-echo": "^1.9.0",
        "mobile-device-detect": "^0.4.3",
        "moment": "^2.27.0",
        "pusher-js": "^7.0.0",
        "twilio-client": "^1.9.7",
        "twilio-video": "^1.20.1",
        "vue-cute-rate": "^1.0.2",
        "vue-dialog-drag": "^0.1.29",
        "vue-i18n": "^8.17.4",
        "vue-loading-overlay": "^3.3.3",
        "vue-native-websocket": "^2.0.14",
        "vue-simple-alert": "^1.1.1",
        "vue-simple-drawer": "^1.0.6",
        "vuelidate": "^0.7.5",
        "vuex": "^3.1.2"
    }
}

webpack.mix.js :

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

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

Searching in net I found page https://cli.vuejs.org/guide/browser-compatibility.html#polyfills-when-building-as-library-or-web-components with :

With Babel we are able to leverage all the newest language features in ES2015+, but that also means we have to ship transpiled and polyfilled bundles in order to support older browsers. These transpiled bundles are often more verbose than the original native ES2015+ code, and also parse and run slower. Given that today a good majority of the modern browsers have decent support for native ES2015, it is a waste that we have to ship heavier and less efficient code to those browsers just because we have to support older ones.

Vue CLI offers a "Modern Mode" to help you solve this problem. When building for production with the following command:

vue-cli-service build --modern

I am not sure if this option must be used in package.json ? In which way? I continu development of this site after other developer and it was supposed that I got working version of the app ...

Activity icon

Started a new Conversation Why Template Literals In JS Code Do Not Work Anymore

Hello, In laravel 5.8 / "vue": "^2.5.17" app checking problems that on several page some data which were shown before and now are not visible I found lines of code, like:

            html_item += `<label class='mt-3 mb-0'>${profession}</label>`;
            html_item += `<h3>${item.user.first_name} ${item.user.last_name}</h3><small></small><div class='star-images'>${star_images}</div><small></small>`;

Where js vars like star_images, profession, item.user.first_name have valid value, but constructions like ${profession} or ${star_images} do not work and content is not rendered. I have never used template literals (ES2015 specification) and wonder why in some moment they stopped to work.

If there is a way programmatically with JS to check if ES2015 specification is On/Off and matually with JS to set in On?

Thanks!

Mar
03
2 months ago
Activity icon

Started a new Conversation How To Get Countries With Related States/cities?

Hello, Are there some libraries/services for Laravel 8 / Alpinejs 2.8 app to get countries with related states/cities? N America, Europe. labels in english... Thanks!

Mar
01
2 months ago
Activity icon

Replied to Why Laravel Components Is Not Rendered Inblade File?

looks like error was in space in a pair:

  :key-name= "KeyValue"

Without spaces it works ok :

            <x-listing-header
                :icon-hint="'Categories of the app'"
                :items-length="count($categories)"
                :items-total-count="$totalCategoriesCount"
            />
Feb
28
2 months ago
Activity icon

Replied to Why Laravel Components Is Not Rendered Inblade File?

I created a new app and uploaded it on github: https://github.com/sergeynilov/ComponentTest

Just on resources/views/welcome.blade.php page I inserted my component and it is not rendered and I see in the browser : https://prnt.sc/109g7dc

But if to remove 2 line :

                                :items-length= "'9'"
                                :items-total-count= "'99'"

component is rendered and I do not see why.

Please take a look. Thanks!

Feb
26
2 months ago
Activity icon

Replied to Why I Got Errors Running Redis In Laravel App?

Searching how test redis I found how made tests, but looks like not all works properly :

app_root$  redis-cli
127.0.0.1:6379> set greetings "Hello World!" 
(error) NOAUTH Authentication required.
127.0.0.1:6379> get greetings 
(error) NOAUTH Authentication required.
127.0.0.1:6379> exit
app_root$ sudo systemctl restart redis
[sudo] password for serge: 
app_root$ redis-cli
127.0.0.1:6379> get greetings 
(error) NOAUTH Authentication required.
127.0.0.1:6379> 

But I am still not sure if it is reason that I got error running laravel-echo-server

Activity icon

Started a new Conversation Why I Got Errors Running Redis In Laravel App?

Hello, I need to run laravel 5 app on my local Kubuntu 18 and I need to run redis server for this app

I installed and in file /etc/redis/redis.conf I uncommented line : requirepass foobared

in .env I modified redis config :

REDIS_HOST=http://127.0.0.1:8000  # I run app with command :  php artisan serve  
REDIS_PASSWORD=foobared
REDIS_PORT=6379 # default port

I restarted redis and check status:


$ sudo service redis status
[sudo] password for serge: 
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-02-26 13:52:09 EET; 6min ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 1545 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 1548 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 1574 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/redis-server.service
           └─1574 /usr/bin/redis-server 127.0.0.1:6379

Feb 26 13:52:08 AtHome systemd[1]: Starting Advanced key-value store...
Feb 26 13:52:09 AtHome systemd[1]: redis-server.service: Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory
Feb 26 13:52:09 AtHome systemd[1]: Started Advanced key-value store.

I see that file Can't open PID file not found above

But I have this file:

[email protected]:/run/redis# ls -la
total 4
drwxr-sr-x  2 redis redis   60 Feb 26 14:32 .
drwxr-xr-x 38 root  root  1160 Feb 26 14:32 ..
-rw-rw----  1 redis redis    6 Feb 26 14:32 redis-server.pid
[email protected]:/run/redis# cat redis-server.pid
22676

and I got error on next command :

$ laravel-echo-server start
Error: The config file could not be found.

Is this errors as PID file was not found above?

In /etc/redis/redis.conf I found

pidfile /var/run/redis/redis-server.pid

When I installed the ubuntu I installed /var on separate partition, so I have in /etc/fstab :

UUID=e531d8c5-530c-4533-a949-9fd5a62e0821 /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sdb1 during installation

UUID=23cc34a1-2be9-43b1-9c79-8e53af7bc799 /boot           ext4    defaults        0       2
# /var was on /dev/sdb5 during installation

UUID=57c14b70-da85-4c5b-be6f-45174147d987 /var            ext4    defaults        0       2

that is why /var/run/redis/redis-server.pid looks like /run/redis/redis-server.pid in my console command. I do not know can that be key of this problem? How can it be salved ?

How can it be fixed?

In composer.json :

        "laravel/framework": "5.5.*",
        "predis/predis": "^1.1",

Thanks!

Feb
22
2 months ago
Activity icon

Replied to Why Laravel Components Is Not Rendered Inblade File?

I made some tests simplified example and removing component I created a new component, but not under admin directory with a command :

php artisan make:component  ListingHeader

and I filled in app/View/Components/ListingHeader.php :

<?php

namespace App\View\Components;

use Illuminate\View\Component;

class ListingHeader extends Component
{

    public $iconHint= '';
    public $itemsLength= 0;
    public $itemsTotalCount= 0;

    public function __construct(string $iconHint= '', int $itemsLength= 0, int $itemsTotalCount= 0)
    {
        $this->iconHint= $iconHint;
        $this->itemsLength= $itemsLength;
        $this->itemsTotalCount= $itemsTotalCount;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|string
     */
    public function render()
    {
        \Log::info(  varDump(-1, ' -1 render ListingHeader::') );
        return view('components.listing-header');
    }
}

and in /resources/views/components/listing-header.blade.php :

<div>
    <h1>resources/views/components/listing-header.blade.php::{{ $iconHint  }}</h1>
    <!-- Very little is needed to make a happy life. - Marcus Antoninus -->
</div>

and writing in parent index.blade.php :

            111111<x-listing-header
                :icon-hint="'Categories of the app'"
            />222222

I see rendered text ok with valid value of $iconHint var But if in parent index.blade.php to pass laravel value :

            111111<x-listing-header
                :icon-hint="'Categories of the app'"
                :items-length= "{{ count($categories) }}"
            />222222

Component is not rendered with double params inside of the component text : https://prnt.sc/103oq9y

Can not catch why so? If which way to pass parameter ? I suppose component rendered on server side and no alpine confusion is possible...

Feb
21
2 months ago
Activity icon

Replied to Seacrch WYSIWYG For Laravel/tailwindcss/Blade/Alpine App?

But can TinyMCE work without jQuery? I have alpinejs2

Activity icon

Replied to Seacrch WYSIWYG For Laravel/tailwindcss/Blade/Alpine App?

Not sure about TinyMCE , seems it also depends on jQuery ?

Activity icon

Replied to Seacrch WYSIWYG For Laravel/tailwindcss/Blade/Alpine App?

I found links to Summernote, but it works on jQuery and Bootstrap, which I do not use

Activity icon

Started a new Conversation Seacrch WYSIWYG For Laravel/tailwindcss/Blade/Alpine App?

Hello, Could you please advice some WYSIWYG editor for Laravel 8 / tailwindcss 2 / Blade / Alpine app?

With instruction to install...

Thanks!

Feb
20
2 months ago
Activity icon

Replied to Why Laravel Components Is Not Rendered Inblade File?

this component is calleded in file index.blade.php

I read in the docs :

To display a component, you may use a Blade component tag within one of your Blade templates. Blade component tags start with the string x- followed by the kebab case name of the component class:

<x-alert/>

<x-user-profile/>

I call my component as :

<x-admin.listing-header

I suppose it follows rules.

Also I read in the docs :

If the component class is nested deeper within the App\View\Components directory, you may use the . character to indicate directory nesting. For example, if we assume a component is located at App\View\Components\Inputs\Button.php, we may render it like so:

<x-inputs.button/>

as my component is located in admin subdirectory.

on the same page other component is called :

    <x-icon-svg :icon="'category'" :title="'Categories of the app'"></x-icon-svg>

and is rendered ok. It was created with command :

php artisan make:component  IconSvg

Can it be subdirectory issue ? But I call listing-header with subdirectory...

Activity icon

Started a new Conversation Why Laravel Components Is Not Rendered Inblade File?

Hello, in my Laravel 8 / tailwindcss 2 / Alpinejs 2.8 app I create laravel component with command

php artisan make:component  Admin/ListingHeader

but calling this component in one of my blade files, like

        <div class="editor_listing_wrapper" x-data="adminCategoryListingComponent()">
            111111<x-admin.listing-header
            :icon-hint="'Categories of the app'"
            :items-length= "{{ count($categories) }}"
            :items-total-count= "{{ $totalCategoriesCount }}"
            />99999999

This component is not renderd, as I see in the browser : https://prnt.sc/zulwm0

I suppose I set valid path in

<x-admin.listing-header

as generated template is located as resources/views/components/admin/listing-header.blade.php

I prefer to create laravel components, but why it is not rendered ? How to fix it ?

app/View/Components/Admin/ListingHeader.php:

<?php

namespace App\View\Components\Admin;

use Illuminate\View\Component;

class ListingHeader extends Component
{
    public $iconHint= '';
    public $itemsLength= 0;
    public $itemsTotalCount= 0;
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(string $iconHint, int $itemsLength, int $itemsTotalCount)
    {
        $this->iconHint= $iconHint;
        $this->itemsLength= $itemsLength;
        $this->itemsTotalCount= $itemsTotalCount;
    }

    public function render()
    {
        return view('components.admin.listing-header');
    }
}

and resources/views/components/admin/listing-header.blade.php :

<div class="p-2 pt-6 mb-4 flex">
    <div class="w-10/12 justify-start align-top">
        <h3 class="m-1 text-center flex items-center d1">
            <x-icon-svg :icon="'category'" :title="'{{ $iconHint }}'"></x-icon-svg>
            <span class="ml-2">
                        {{ $itemsLength }}&nbsp;@choice('category|categories', $itemsLength) from {{ $itemsTotalCount }}
                        </span>
        </h3>
    </div>
    <div class="w-2/12 m-1 flex justify-end items-center align-top d2">
                    <span @click="refreshCategoriesListing()" class="mr-5">
                        <x-icon-svg :icon="'refresh'" :title="'Refresh categories listing'" ></x-icon-svg>
                    </span>
        <span onclick="document.location.href='{{ route('admin.categories.create') }}'">
                        <x-icon-svg :icon="'add'" title="Add new category" ></x-icon-svg>
                    </span>
    </div>
</div>

Thanks!

Feb
17
2 months ago
Activity icon

Started a new Conversation How To Make Listing With Pagination With Pretty Url

Hello, In laravel 8 I try to make listing with pagination with url like

http://site.com/admin/categories/page/3

and looking at branch https://stackoverflow.com/questions/20974404/laravel-pagination-pretty-url I tried to remade it for laravel 8 , replacing method getCurrentPage with ->path() method :

        $links = $categories->links();
        $patterns = array();
        $patterns[] = '/'.$categories->path().'\?page=/';
        $replacements = array();
        $replacements[] = '';
        echo '<pre>$patterns::'.print_r($patterns,true).'</pre>';
        echo '<pre>$replacements::'.print_r($replacements,true).'</pre>';
        // echo '<pre>$links::'.print_r($links,true).'</pre>';
         echo  preg_replace($patterns, $replacements, $links);

I see output :

$patterns::Array
(
    [0] => //admin/categories\?page=/
)
$replacements::Array
(
    [0] => 
)

But I got error :

preg_replace(): Unknown modifier 'a' (View: .../admin/categories/index.blade.php)

I tried to wrap like :

  $patterns[] = '/'.preg_quote( $categories->path() ).'\?page=/';

Or

  $patterns[] = '/'.addslashes( $categories->path() ).'\?page=/';

but got the same error anyway.

Which way is valid?

Thanks!

Feb
16
2 months ago
Activity icon

Replied to How Install Laravel-datatables-oracle Without Jquery ?

Are there some replacement of yajra/laravel-datatables with apline / tailwindcss ?