theblack68

Member Since 4 Years Ago

Cassano Magnago

Experience Points
20,010
Total
Experience

4,990 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
175
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
20,010 XP
Mar
01
12 hours ago
Activity icon

Awarded Best Reply on Undefined Index

Resolved Sorry to all ;)

Activity icon

Replied to Undefined Index

Resolved Sorry to all ;)

Activity icon

Started a new Conversation Undefined Index

Sorry but I'm going crazy ...it has always worked ... from today i get this error but i can't understand what it could be.

I import an Excel file with maatwebsite excel, map it and do a massive update of the values. I don't why happen UNDEFINED INDEX CAVO

public function update(Request $request, ExcelImport $excel_importer)
    {
        $data = $excel_importer->import(request('import_file'));
        $chiavePrimaria = 'cavo';

        //sinistra: colonne excel - destra: colonne DB
        $mappa = collect([
            'master' => 'master',
            'cavo' => 'cavo',
            'pnf' => 'pnf',
            'fornitore_id' => 'fornitore_id',
            'descrizione' => 'descrizione',
            'descrizione_metel' => 'descrizione_metel',
            'stato_id' => 'stato_id',
            'tipologia_id' => 'tipologia_id',
            'categoria_id' => 'categoria_id',
            'cu_attuale_diff' => 'cu_attuale_diff',
            'cu_kg_km' => 'cu_kg_km',
            'moltiplicatore' => 'moltiplicatore',
            'netto_acquisto_vr15' => 'netto_acquisto_vr15',
            'base_cu' => 'base_cu',
            'netto_acquisto_cu_attuale' => 'netto_acquisto_cu_attuale',
            'q_minima' => 'q_minima'
        ]);

        if (count($data) == 0) {
            return redirect()->back()->with('not_possible', 'Non hai caricato nessun file oppure il file caricato è vuoto');
        }
        foreach ($data as $importRecord) {
            $record = Cavo::where($mappa[$chiavePrimaria], $importRecord[$chiavePrimaria])->first();
            $dataMap = collect($mappa)->values()->combine(collect($importRecord)->values())->toArray();
            // add @count for issue: Parameter must be an array or an object that implements Countable php 7.2
            if (@count($record) == 0) {
                $reportImportedRecord = $dataMap['cavo'];
                return redirect()->route('cavi.report')->with('not_possible', $reportImportedRecord);
            }

            $record->update($dataMap);
        }
        return redirect()->route('cavi.aggiornamento');
    }

Thanks for eventually Help...

Feb
23
6 days ago
Activity icon

Replied to Laravel Debugbar (MODEL)

Thanks I will look for some resource to read ... I offer a virtual beer;)

Activity icon

Replied to Laravel Debugbar (MODEL)

No @tykus I don't need all the records at once ... pagination does it directly datatables.

Activity icon

Replied to Laravel Debugbar (MODEL)

@tykus thanks for response ...I'm pretty new with Laravel ... what should I do about it since I work with Datatables? Server Side?

Activity icon

Started a new Conversation Laravel Debugbar (MODEL)

Hi ...I'm use a debugbar in a project and I Work with datatables (in blade I do a foreach for iterate the collection)

I have see that in the model load:

51 App\Models\Role

52 App\Models\User

I asked myself ... but if I retrieve thousands of records the model (example will mark 6000) does it affect system resources?

Am I wrong something?

Jan
03
1 month ago
Activity icon

Awarded Best Reply on Laravel 8 Middleware('auth') And Custom Guards

I have see in depth the Authenticate Middleware and I have found a method handle. This has the ability to get the guards. So I have declared a protected property $guards and return the parent handle method.

protected $guards;

    public function handle($request, Closure $next, ...$guards)
    {
        $this->guards = $guards;
        return parent::handle($request, $next, ...$guards);
    }

And after with this I have check in the method RedirectTo:

if (! $request->expectsJson()) {
            if (Arr::first($this->guards) === 'admin') {
                return route('admin.login');
            }

            return route('login');
        }

...maybe someone have the same problem ;)

Activity icon

Replied to Laravel 8 Middleware('auth') And Custom Guards

I have see in depth the Authenticate Middleware and I have found a method handle. This has the ability to get the guards. So I have declared a protected property $guards and return the parent handle method.

protected $guards;

    public function handle($request, Closure $next, ...$guards)
    {
        $this->guards = $guards;
        return parent::handle($request, $next, ...$guards);
    }

And after with this I have check in the method RedirectTo:

if (! $request->expectsJson()) {
            if (Arr::first($this->guards) === 'admin') {
                return route('admin.login');
            }

            return route('login');
        }

...maybe someone have the same problem ;)

Jan
01
2 months ago
Activity icon

Replied to Laravel 8 Middleware('auth') And Custom Guards

Thanks @redroseamit I already use Laratrsut ...I'm interesting now the native opportunity of Laravel.

Activity icon

Started a new Conversation Laravel 8 Middleware('auth') And Custom Guards

Hi ...I'm try to build, for learn better Laravel, a multiple Auth login.

I have create 2 form login one for Users and one for Admins. I have also create a custom guard called admin.

I have now two dashboards: AdminDash and UserDash ...my goal is, when someone try to go directly to one of this dashboard redirect to the right login page.

I'm use a middleware('auth') that is hardcoded and redirect back to login page.

I have resolved with this code in the redirectTo method in the authenticate Middleware.

protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            if($request->getRequestUri() == '/admin/dashboard') {
                return route('admin.login');
            } else {
                return route('login');
            }
        }
    }

or maybe I can overwrite this method:

protected function unauthenticated($request, array $guards)

But I don't know if is the best method ...someone can give me an advise?

Thanks!

Dec
12
2 months ago
Activity icon

Awarded Best Reply on Cursed Storage

I have resolved with return a response in Controller.

I have create a route with some middleware

Route::get('images/{file}', [\App\Http\Controllers\CardController::class, 'getImage'])
    ->middleware(['auth:sanctum', 'verified']);;

And in te controller

/ / Check if file exists
        if (! File::exists(storage_path('immagini/' . $file))){
            abort(404, 'Non sei Autorizzato a visualizzare questa risorsa!');
        }

        $path = storage_path('immagini/' . $file);
        return response()->file($path);

...and finally in a view

<table id="cards" class="display" style="width:100%">
            <thead>
            <tr>
                <th>Titolo</th>
                <th>Anno</th>
                <th>Registro</th>
                <th>Tecnica</th>
                <th>Collezione</th>
                <th>Status</th>
            </tr>
            </thead>
            <tbody>
            @foreach($cards as $card)
            <tr>
                <td>
                    <img src="{{ $card->copertina }}" width="100" />
                    {{ $card->titolo }}
                </td>
                <td>{{ $card->anno }}</td>
                <td>{{ $card->registro }}</td>
                <td>{{ $card->tecnica }}</td>
                <td>{{ $card->collezione_privata }}</td>
                <td>{{ $card->checked }}</td>
            </tr>
            @endforeach
        </table>
Activity icon

Replied to Cursed Storage

I have resolved with return a response in Controller.

I have create a route with some middleware

Route::get('images/{file}', [\App\Http\Controllers\CardController::class, 'getImage'])
    ->middleware(['auth:sanctum', 'verified']);;

And in te controller

/ / Check if file exists
        if (! File::exists(storage_path('immagini/' . $file))){
            abort(404, 'Non sei Autorizzato a visualizzare questa risorsa!');
        }

        $path = storage_path('immagini/' . $file);
        return response()->file($path);

...and finally in a view

<table id="cards" class="display" style="width:100%">
            <thead>
            <tr>
                <th>Titolo</th>
                <th>Anno</th>
                <th>Registro</th>
                <th>Tecnica</th>
                <th>Collezione</th>
                <th>Status</th>
            </tr>
            </thead>
            <tbody>
            @foreach($cards as $card)
            <tr>
                <td>
                    <img src="{{ $card->copertina }}" width="100" />
                    {{ $card->titolo }}
                </td>
                <td>{{ $card->anno }}</td>
                <td>{{ $card->registro }}</td>
                <td>{{ $card->tecnica }}</td>
                <td>{{ $card->collezione_privata }}</td>
                <td>{{ $card->checked }}</td>
            </tr>
            @endforeach
        </table>
Activity icon

Replied to Cursed Storage

@michaloravec I have already tried but it doesn't work

Activity icon

Started a new Conversation Cursed Storage

Hi ...Are 2 hour that I try to resolve this problem.

I'm work in local with Homestead and Vagrant and Laraavel 8.x and JETSTREAM (all configured)

I'm try to build a simple application (I want learn good Laravel)

I have 2 simple Model Card and Picture with relative Controller.

All the route are accessible after verification the Email.

I have create a directory pictures in storage with all the images (so is not access from public)

I'm try to return in a view for each card a thumbnail of the image {{ asset('storage/pictures/name.extension) }}

...but nothing not works.

I have do a dd(File::exists(storage_path('pictures/1.jpg'))) => response is true!

In a view I have try also {{ \Illuminate\Support\Facades\Storage::url('immagini/1.jpg') }}

But I can't show in a View ;(

Dec
10
2 months ago
Activity icon

Started a new Conversation Permission AWS S3 Bucket

Hi ...I try to use Aws s3 Bucket.

I want build an application that storage the images on S3. I have try with code in Laravel and all works fine.

I have only a big question: How I set the permission: I have 4 option in S3 but I don't undestand what checked.

My application store only Images and all are public.

Thanks

Nov
29
3 months ago
Activity icon

Replied to Markdown And Tailwind Css

thanks ;)

Activity icon

Replied to Markdown And Tailwind Css

Thanks @snapey ...I have understand this concept. What not is really clear is: the body become from the database table from column body with different tag => how I create custom style?

<h1>Title</h1>
<p>Body</p>
<em>Example</>

maybe:

.markdown h1 h2 h3 {
	text-white,
	....
}

thanks

Activity icon

Replied to Markdown And Tailwind Css

Thanks for the response @snapey .

Really I haven't understand ;(.

...I'm new with tailwind ...thanks.

Activity icon

Started a new Conversation Markdown And Tailwind Css

Hi...

Someone can help me with this strange behavior?

I use a mail markdown for a body of my post:

{{ Illuminate\Mail\Markdown::parse($article->body) }}

All markdown works right apart the Hx style (1, 2, 3 ...). This happen when I have the:

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

...I have try to find the solution but nothing ;(

Nov
26
3 months ago
Activity icon

Replied to Rule Unique

@nakov yes ;) resolved thanks !!

Activity icon

Replied to Rule Unique

@nakov I have check with a dd and is right.

The scenario is this: I have a User that have an Account (one to one relation).

So in the accounts table I have a field user_id.

So I insert in the Rule the auth()->user()->account->id (so I'm sure to retrive the right record to update.

but nothing ;(

Activity icon

Started a new Conversation Rule Unique

Hi ...I have try to find solution without success.

I try to ignore an id when update a record.

I have a table called accounts, and a function that do the validation ($this->validate).

I have insert on VAT the rule

Rule::unique('accounts')->ignore($this->id)

...but not work.

Someone have advise?

Thanks

Nov
18
3 months ago
Activity icon

Replied to Pass Data To Component

I have this scenario:

PageController

public function show($id)
{
	$page = Page::findOrFail($id);
	return view('page.index', compact('page'));
}

In the view page I have a component called content.

How I can pass the $page variable from controller to this component like so?

<x-content>

$page->id

$page->name

....

</x-content>

Maybe is a stupid question because I haven't understand how work the components?

Thanks for the hel ;)

Nov
09
3 months ago
Activity icon

Awarded Best Reply on Laravel 8 Jetstream And Tailwind

After restart Mac and vagrant all works right ;)

Thanks for support ;)

Activity icon

Replied to Laravel 8 Jetstream And Tailwind

After restart Mac and vagrant all works right ;)

Thanks for support ;)

Activity icon

Replied to Laravel 8 Jetstream And Tailwind

I have found a strange behavior ...in firefox not work in Chrome yes, in Safari yes!

I have try from console in firefox to edit a css => when I change any value the css work.

Very strange...

Activity icon

Replied to Laravel 8 Jetstream And Tailwind

I get no error in network tab and in the css file exist the class.

I have try a new fresh installation without jetstream and all work ...with jetstream not work ;(

Activity icon

Replied to Laravel 8 Jetstream And Tailwind

Yes I have installed

npm install tailwindcss

after:

npm run dev

but nothing ...this is my webpack.config.js

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

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css', [
        require('postcss-import'),
        require('tailwindcss'),
    ])
    .webpackConfig(require('./webpack.config'));

and this the tailwind.js

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {
    purge: [
        './vendor/laravel/jetstream/**/*.blade.php',
        './storage/framework/views/*.php',
        './resources/views/**/*.blade.php',
    ],

    theme: {
        extend: {
            fontFamily: {
                sans: ['Nunito', ...defaultTheme.fontFamily.sans],
            },
        },
    },

    variants: {
        opacity: ['responsive', 'hover', 'focus', 'disabled'],
    },

    plugins: [require('@tailwindcss/ui')],
};

...need something more?

Activity icon

Started a new Conversation Laravel 8 Jetstream And Tailwind

I'm go crazy ;)

Sorry ...before post I have read some documentation but I can't find the solution.

I have a Laravel project with jetstream ...I want implement tailwind with all css (full).

I have duplicate the dashboard view and renamed test => after I have replace qith this snippet:

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="bg-indigo-700">
            <div class="max-w-2xl mx-auto text-center py-16 px-4 sm:py-20 sm:px-6 lg:px-8">
                <h2 class="text-3xl leading-9 font-extrabold text-white sm:text-4xl sm:leading-10">
                    <span class="block">Boost your productivity.</span>
                    <span class="block">Start using Workflow today.</span>
                </h2>
                <p class="mt-4 text-lg leading-6 text-indigo-200">Ac euismod vel sit maecenas id pellentesque eu sed consectetur. Malesuada adipiscing sagittis vel nulla nec.</p>
                <a href="#" class="mt-8 w-full inline-flex items-center justify-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-indigo-600 bg-white hover:text-indigo-500 hover:bg-indigo-50 transition duration-150 ease-in-out sm:w-auto">
                    Sign up for free
                </a>
            </div>
        </div>
    </div>
</x-app-layout>

When I write the code, the intellisense correctly proposes tailwind ... so it's present in the css.

But not apply the style ...someone can help me to understand?

Thanks ;)

Nov
05
3 months ago
Activity icon

Replied to Laravel Dompdf

Thanks laracroft ...I have finish now to test it ;)

All works right with the memory_limit in the job.

Great ;)

Activity icon

Replied to Laravel Dompdf

Thanks laracroft ...I try now.

I hope don't receive the error anyway ;(

Activity icon

Replied to Laravel Dompdf

I didn't understand how to do without the controller.

I think you intend to set a cron at a time of day?

In case what changes in terms of memory limits?

...because I have set ini_set('memory_limit', -1) but I get the same error.

After about 170 record processed I get the error ;(

Activity icon

Replied to Laravel Dompdf

Hi laracroft ...

A better place to put such long running tasks is a command/job, a web controller's method is not a good place...

Would you mind helping me with some advice for this task?

Thanks a lot

Nov
04
3 months ago
Activity icon

Started a new Conversation Laravel Dompdf

Hi!

I have set a jobs for save 600 pdf. In a foreach I generate a pdf and I save it in storage. All the procedure works fine but some times I get the error "allowed memory size..."

This is my code:

Job


class ProcessPdf implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $associate;

    /**
     * Create a new job instance.
     *
     * @param Associate $associate
     */
    public function __construct(Associate $associate)
    {
        $this->associate = $associate;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $path = storage_path('app/downloads/pdf/' . $this->associate->ragione_sociale . '_' . $this->associate->codice_contribuente . '.pdf');
        PDF::loadView('prints.print', ['associate' => $this->associate])->save($path);
    }
}

This is the controller:


ini_set('memory_limit', '300M');
        foreach($associates as $associate) {
            ProcessPdf::dispatch($associate);
        }
        return redirect('associates')->with('ok_message', 'Il processo di Generazione PDF è iniziato.');

Someone can give me some advise for a best pratic?

Thanks

Oct
26
4 months ago
Activity icon

Started a new Conversation Pass Data To Component

Hi ...sorry for the question but I try something that maybe is wrong.

I have create a component named "Rendering" with comand php artisan make:component Rendering.

This has create 2 files.

I have a RenderingController with a method that return a view renderings.blade.php with a variable called $logoRendering.

I have insert in this view (rendering.blade.php) the code :

...and I have create a public property in Rendering.blade, with relative __construct.

For the final step I have insert, in component/rendering.blade.php, the Output of the $logoRendering variable.

But I get the error Undefined variable: logoRendering ...Someone can help me please?

Thanks ;)

Oct
23
4 months ago
Activity icon

Replied to Strange Behavior Author Role

thanks ;(

Activity icon

Started a new Conversation Strange Behavior Author Role

Hello ...I have read that the author role in wordpress not allow ti edit other post. I have create, on my site, a user with role author => I can Edit a post create from administrator ...some help?

Thanks