thewebartisan7

Member Since 2 Years Ago

Experience Points
39,550
Total
Experience

450 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
166
Lessons
Completed
Best Reply Awards
33
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 8
39,550 XP
Dec
08
1 month ago
Activity icon

Replied to Form Request: Convert Error Message In Json

Why you want to change the structure of JSON? The structure above exists beacuse an attribute can have multiple validations messages, so it's correct that is an array. If you want to show just first one, then access array using first index. Maybe try explain why you want to change structure, how you are using it on frontend.

Nov
28
1 month ago
Activity icon

Replied to Which Platform Is The Best To Sell A Laravel App / Script?

I am looking for also for an alternative to envato. I find a few, but didn't yet try anyone. If you find something else, please to share.

Below is what I found, is not dedicated to Laravel, but in general for anything:

https://www.pkgkit.com/

https://www.codecake.net/

https://repobox.io/

https://codeclerks.com/

https://www.codegrape.com/

https://www.codester.com/

or also use gumroad.com

Nov
23
1 month ago
Activity icon

Replied to Limit The Number Of Records Created Per Day In A Model

You can programmatically handle rate limit, so you can avoid to increase limit when validation fail. An example can be like Laravel UI login throttles:

https://github.com/laravel/ui/blob/3.x/auth-backend/ThrottlesLogins.php

Activity icon

Replied to How Can I Implement WithoutGlobalScopes With Route Model Binding

In your service provider, boot method, you can define an explicit route model binding.

Example:

        $this->app->router->bind('userWithoutScopes', function ($id) {
            return User::withoutGlobalScopes()->findOrFail($id);
        });

Then use in your routes, {userWithoutScopes}

See https://laravel.com/docs/8.x/routing#explicit-binding

Activity icon

Replied to I Need To Validate A Field Which Cannot Be True If Another Field Is Greater Than 0

Try apply the custom rule to "services" only. Then $value should be whole services array:



 'services' => [
   'required',
   'min:1',
   'array',
   function($attribute, $value, $fail) {
                    
          // $value is whole $services array, so you can loop over it as Talinon suggest
		   
           return $fail('VAT required');
     }
],
Activity icon

Replied to Ignore Field On Update Using Unique On Custom Request

Required rule should not be problem.

It's strange, I could only think that there are another user with that email, did you already check this?

You could also try with a custom route to see if works, by keeping only one validation, like:


Route::put('/api/users/{user}', function ($user) {
    
    request()->validate([
      'email' => "required|email|unique:users,email,{$user},id",
    ]);
});

Activity icon

Replied to Ignore Field On Update Using Unique On Custom Request

It's seem correct. You are not using route model binding.

What you get when you do dd($this->user) in UpdateUserRequest?

Nov
22
1 month ago
Activity icon

Replied to Repository Pattern In Laravel

The repository pattern was first introduced by Martin Fowler in the book "Patterns of Enterprise Application Architecture", and was designed for enterprise applications to reduce duplication of query logic. Then it evolve keeping the same name.

There are use case, but if a pattern exist doesn't mean you need it. Don't over abstract. Don't over engineer.

As jlrdw said, you can keep everything in Model and still keep code clean, even more cleaner if you are not working on some enterprise applications.

Activity icon

Replied to Jetstream

After Jetstream release:

Dammit, they are still using Laravel UI.

...

Let's make Laravel Breeze.

...

Dammit, they are still using Laravel UI.

...

Just joking here ;)

But I could not disagree with jlrdw, Laravel Breeze seem just another try to push tailwind.

I still prefer Laravel UI, I like the usage of Traits, where you override only what you need. Also it has already several presets, even for tailwind, so not sure why get yet another auth package.

About OP questions, don't worry if Laravel UI is not in docs, because Taylor said that will be mainteined in future, we all hope. Also it doesn't need too much docs to get started, just installation, but that it's easy.

Nov
19
1 month ago
Activity icon

Awarded Best Reply on How To Log Out All Users Site Wide?

If you regenerate key in .env then it should did the trick:

php artisan key:generate

This will also logout user with remember me.

Deleting only database table if you are using database sessions or deleting sessions files, will not logout users that login with remember me.

If there are other implications to consider using this approuch depend on your project, since this will break all encryption, so pay attention to this.

Activity icon

Replied to How To Log Out All Users Site Wide?

If you regenerate key in .env then it should did the trick:

php artisan key:generate

This will also logout user with remember me.

Deleting only database table if you are using database sessions or deleting sessions files, will not logout users that login with remember me.

If there are other implications to consider using this approuch depend on your project, since this will break all encryption, so pay attention to this.

Nov
17
2 months ago
Activity icon

Awarded Best Reply on How To Custom Response JSON Object Validator

Because you can have more than one validation messages, for this reasons is an array.

You can on client side loop over each messages and display all or only first.

If you want to handle this on server side, there is several way.

If you know upfront all field name, then you could:

return response()->json([
   'name' => $validator->errors()->first('name'),
   'password' => $validator->errors()->first('password'),
], 400);

Something more generic could be to convert first in a collection, and then you can build new errors array, see https://laravel.com/docs/8.x/collections

For example:

$errors = collect($validator->errors())
              ->reverse()
              ->mapWithKeys(function ($item, $key) {
            return [$key => $item[0]];
        });

But maybe there is better way with collection. I think reverse is required so that first message is not overriden by last.

To get first message on client side would be something like:

// Taking into account that you are using axios which return response in error.response.data
error.response.data.errors[Object.keys(error.response.data.errors)[0]]

And for loops all errors:

                       let errors = error.response.data.errors
                        for (let input in errors) {
                            if (errors.hasOwnProperty(input)) {
                             // First error
                             invalidFeedback.innerHTML = errors[input][0]
                            }
                        }
Activity icon

Replied to Packages Development

See here also free resource https://laravelpackage.com/

Nov
04
2 months ago
Activity icon

Awarded Best Reply on How To Retain Selected Table When The Page Loads

If you mean to save state even if you change page and return back, then you can save the state in local storage.

Something like:


$(function () {

  $('#btnAnalysis').on("click",function(){
    
    
    // Your code

    // Save state in local storage
    window.localStorage.setItem('selectedTable', 'analysis');

  });

  $('#btnDicom').on("click",function(){

    
    // Your code


    // Save state in local storage
    window.localStorage.setItem('selectedTable', 'dicom');


  });

   // Check if state exist
   if(window.localStorage.getItem('selectedTable') === 'analysis')  
	$('#btnAnalysis').trigger("click");

   else if(window.localStorage.getItem('selectedTable') === 'dicom')  
	$('#btnDicom').trigger("click");

})
Activity icon

Replied to How To Retain Selected Table When The Page Loads

If you mean to save state even if you change page and return back, then you can save the state in local storage.

Something like:


$(function () {

  $('#btnAnalysis').on("click",function(){
    
    
    // Your code

    // Save state in local storage
    window.localStorage.setItem('selectedTable', 'analysis');

  });

  $('#btnDicom').on("click",function(){

    
    // Your code


    // Save state in local storage
    window.localStorage.setItem('selectedTable', 'dicom');


  });

   // Check if state exist
   if(window.localStorage.getItem('selectedTable') === 'analysis')  
	$('#btnAnalysis').trigger("click");

   else if(window.localStorage.getItem('selectedTable') === 'dicom')  
	$('#btnDicom').trigger("click");

})
Nov
03
2 months ago
Activity icon

Awarded Best Reply on Laravel Charts Compatible With Laravel 8x?

There is the same issue on github of that repo and author just advise that issue is caused by wrong PHP version, see https://github.com/ConsoleTVs/Charts/issues/623

It's depend your local server which version are using, most probably it's not using PHP 7.4

If you using valet you can switch php version, see https://laravel.com/docs/8.x/valet#php-versions

Any other *amp software, check in their docs how to change php version, for example with mamp you can do that.

Activity icon

Replied to Laravel 8 - Undefined Variable: Header?

Altought I don't use this approuch, but one or another, you could allow layout to works as component or using old extends method. This could be a solution in case some page are using layout as slot but you want extend it.

@hasSection('header')
    <div class="pull-right">
        @yield('header')
    </div>

    <div class="clearfix"></div>
@else
{{ $header ?? null }}
@endif

This way if layout is extended and has section header it will be placed inside, otherwise $header slot will be used.

For main content/slot similary:

            @hasSection('content')
                @yield('content')
            @else
                {{ $slot }}
            @endif
Activity icon

Replied to Laravel Charts Compatible With Laravel 8x?

There is the same issue on github of that repo and author just advise that issue is caused by wrong PHP version, see https://github.com/ConsoleTVs/Charts/issues/623

It's depend your local server which version are using, most probably it's not using PHP 7.4

If you using valet you can switch php version, see https://laravel.com/docs/8.x/valet#php-versions

Any other *amp software, check in their docs how to change php version, for example with mamp you can do that.

Activity icon

Replied to Problem With Search In Laravel Equivalent

it works, but will the user expect a result if they enter UKŁAD AUDI ?

Exploding search as array yes.

Its not been maintained for a while but works well https://github.com/nicolaslopezj/searchable

Not sure how performant are this query created by package since it search for each word, with all wildcards variants. I think native full text search would be much better in this case, and you can also order by relevance.

Activity icon

Replied to Laravel Charts Compatible With Laravel 8x?

The error you guys are facing is because whatever php version is parsing the laravel app is lower than 7.4 as is unable to understand short closures like:

fn (Application $app) => new Registrar(...)

There is 2 PHP versions that need to be at 7.4. The PHP CLI (used to install dependencies using composer or run php artisan) and PHP fpm (used by nginx). You need BOTH at 7.4.

Activity icon

Replied to I Would Like When Someone Clicks On My Div That He Will Be Directed To A New Window

Did you try my solution? It's the only way, you can't make div clickable because iframe is on top, and iframe is interactive. For security reason iframe can't interact with top window object. Another solution if your iframe just dispay something without need to interact with it, is to add pointer-events: none; to iframe. Then you can wrap whole iframe with link, example:

<a href="https://uk.yahoo.com">

    <iframe class="producd-360-iframe" src="https://www.pngonly.com/wp-content/uploads/2017/06/Amazon-Logo-PNG-Image-210x47.png" allowfullscreen="" width="600" height="600" frameborder="0"

     style="pointer-events: none;"> </iframe>

</a>
Nov
02
2 months ago
Activity icon

Replied to Laravel Charts Compatible With Laravel 8x?

That package works only with php 7.4+, most probably you have lower php version. I use it and works fine with laravel 8.

Activity icon

Replied to Problem With Search In Laravel Equivalent

I see now. The performance depend on how many records you have. LIKE is usually very slow when you use wildcard in the beginning because can't be indexed, it will scan whole table to find match. It can works fine for small table. Alternatively with mysql you can check into https://dev.mysql.com/doc/refman/5.7/en/fulltext-search.html but also this is not so good for large table. See here an example https://arianacosta.com/php/laravel/tutorial-full-text-search-laravel-5/

Postgresql has some better native functions to handle this, but not sure if you wish to use it. The question can be complicated depending on how many records you have to handle. Sometimes third party service like algolia or this new promising https://www.meilisearch.com/ are the only way.

Start with some basic solution and be ready to upgrade when need.

Try test performance comparison between splitting search as array in single words compared to your solution with str_replace. It will be more accurate but maybe a bit slower.

 $arrayOfWords = explode(' ', $request->search);
foreach ($arrayOfWords as $word) {
   $query->orWhere('category_name', 'LIKE', "%$word%");
// Or also try find exact match will be a bit faster
  $query->orWhere('category_name', $word);
// or try use wildcard only in the end, also faster
$query->orWhere('category_name', 'LIKE', "$word%");
}
  	
Nov
01
2 months ago
Activity icon

Replied to Problem With Search In Laravel Equivalent

@snapey I know that are not case sensitive by default, but it depend also on utf8_bin collation that he may change via laravel configuration. As I take into account that his query is correct, and that he has the record on database, then it may be that the problem.

Activity icon

Replied to Problem With Search In Laravel Equivalent

Try for each filter:

$query->orWhereRaw("LOWER('category_name') LIKE ?", ["%{$request->search}%"])

Also be sure to lowercase search from request using:

$q = mb_strtolower($request->search, 'UTF8');

You can also use ->pluck('value', 'id'); instead of creating array after.

$categories = Category::select('id', 'value')
                    ->where(function ($query) use ($request) {
                        ///...
                    })->active()
                    ->orderby('order', 'asc')
                    ->pluck('value', 'id');
return $categories;

See https://laravel.com/docs/8.x/collections#method-pluck

Activity icon

Replied to I Would Like When Someone Clicks On My Div That He Will Be Directed To A New Window

Since you are using bootstrap you can archive this without JS using .stretched-link, see below example.

<div class="col-md-6 col-xs-12 producd-360 noPadLeft">
// Your link will cover full parent div,  target is optional
<a class="stretched-link" target="_blank" href="http://google.com"></a>

  <iframe class="producd-360-iframe" src="https://ir.ebaystatic.com/rs/v/fxxj3ttftm5ltcqnto1o4baovyl.png" allowfullscreen="" width="600" height="600" frameborder="0"> </iframe>
</div>

Source https://getbootstrap.com/docs/4.5/utilities/stretched-link/

The parent div must have position: relative, and col-* class has already it. In case you can add utility class .position-relative

Activity icon

Replied to Do You Really Like Tailwind And Livewire ?

...
.headTxt{float:none;width:100%;margin-top:15px;}
.personnel.resource.cMaterial{background:#57595b;}
.personnel.resource.lab{background:#ce2449;}
.left-course .whatList li.welcome h3{font-size:22px;}
.gdpr-List.newsFeedList li .profileDiv .contentWrp .readB{margin-top:25px;}
.innerService .serv li h2{font-size:24px;width:90%;}
.innerService .serv li .block h4{font-size:22px;}
....

This is not fault of bootstrap, but of developer who made it, which could do similar mess also with tailwind. This doesn't follow bootstrap best practice of OOCSS. Bootstrap use BEM methodology (http://getbem.com/introduction/ ) combined with utility classes since version 2, and with version 5 this are also extendible as you wish. It's first inception was in 2013 with so called "atomic css". So is nothing new coming with tailwind. Most of above css properties has utility class in bootstrap.

A good combination of both is the best way to go, where you define top level component and then down level use utility.

Also with tailwind you can't make everything with classes, you have to do some custom css. So you will end up in adding custom classes somewhere.

With tailwind above example would be converted also in one line, or in HTML component as class name or inside css @apply inline class name. So I don't see too much difference here.

Oct
27
2 months ago
Activity icon

Replied to Do You Really Like Tailwind And Livewire ?

Snapey I see that you can disable all requests of Livewire and reduce to single requests but then that become like normal ajax form submissions that you can easily do via JS with a few lines of code, for every forms, not just for single form, by creating a generic function that can be re-used. So when I create new ajax form, I don't write anymore new JS code, but just adding a data attribute such as data-ajax-form and then I have an event listener that process all forms with this attribute. And I can add extra code via on success event if I need.

Almost every JS code that I write can be re-used, so you end up without writing any JS code but only using HTML5 data attributes for initialize and configure the code.

About your example of username, there is a package that I used in past laravel-jsvalidation that allow to do remote validation for any field you want without creating a new endpoint and without writing any JS. Right now I am not using it since checking an alternative without jquery. But I mean is that something like that was already available. And even without this package you can archive the same by passing to server an extra param like validation=true and then on server side validate only field in the same action, something like you do with Livewire for validate single field using a method. Similar method you could have in controller, called by action when found param that you define.

I will say an obviously thing by saying that Livewire is written also in Javascript. And that you don't need to write anymore Javascript is not totally true. If you want to reduce server request like for open a modal, then you need to find a way via AlpineJS, which is not totally easy to understand and use. Yes for small interaction, but when you need to deal other plugins often become hard to manage.

I saw also all video of Caleb. Even if his videos are nice to watch, they raise even more questions regarding Livewire. For example his last video of datatable, you see that he make a request for every single interaction such as open a modal, toggle filters, etc. Then he said in video that this can be done via AlplineJS but why he don't do that? Just to show that everything can be done without writting any JS. Ok but this raise other problem with too many requests. Because all this status must be sent to server to livewire component to be aware of current state in order to hide/show and prepare variables. Then he end up with some caching of database query using component ID. I am not sure how much are this performante since that ID is unique for each request. Having many users using the same component would not make happy sysadmin.

I want to not being misunderstand, I am don't want to speak something against Livewire to not offend who love it, also much of respect for Caleb. But it's not a good solutions for every developer. For many others can be something awesome.

Regarding tailwind, the first solution to extract utility classes go against the concept of framework, if you do that then you are basically doing what bootstrap already offer. While second solution using component, apart that this make you create a single component for each element you have, for example Jetstream has even for single link in menu, ending up with 90+ views loaded in single edit profile page. But another problem that this second solution seem can't solve is when you need to override single or a few classes of a component. Example you want to change a background color, and so also text color, and let say padding. Using attributes->merge you can't override classes in component, you can only add new classes. This will end with a lot of classes in several views and not local. Marcel Pociot make a video regarding this by proposing a solution, but this seem still not yet updated, see https://twitter.com/marcelpociot/status/1310935864848117760 Another thing is that often you need to create multiple elements in single page for mobile and desktop, this for example for menu, as also Jetstream is doing. Having a large menu, is a lot of duplicated code.

The principle of CSS was (and I hope continue to be) that you have single CSS files that you share across many pages, and by just changing them you don't need to change HTML, csszengarden.com is perfect example of this. With tailwind seem opposite, you never change CSS but you need to change HTML. But this raise problem above.

Someone claim that you just work with classes and not anymore with compilation etc. But if you want to get full potential of tailwind you need to setup your classes in smart way using configuration file, extraction etc. This is not only changing of classes anymore.

Oct
26
2 months ago
Activity icon

Replied to Do You Really Like Tailwind And Livewire ?

Yes I agree that with vanilla js you have to write a bit more code but in the end is faster.

But you could create your own small wrapper around most common DOM manipulation that you are using in your project.

Or use some existing, there are several. One of most near jquery API is:

https://github.com/fabiospampinato/cash

It's most probably that most of your jquery code will work with cash without need to change anything.

About fetch I still prefer to use axios because it has several features out of box.

Activity icon

Replied to Do You Really Like Tailwind And Livewire ?

Seem that I was reading my own thoughts :) But I even don't like Fortify, I think that Fortify is main problem.

I also make a month ago a fortify UI with all features as jetstream, but as a package, so it's easy to install. But it was frustrating. Once I hear that laravel ui will be still mainteined I do the same but with laravel ui, much quicker as I already know where to put my hand.

Here is final result https://gyazo.com/75d46b386d7d3cec206fef967b4bd4c4 Everything is ajax, from form submission to navigation with turbolinks 5.

I agree also about tailwind, and with coming bootstrap 5 there is also way to create utility classes as you need. So is good mix of components and utility. Apart Adam tailwindui I can't find something good with it. But I will try again to work with it as when I have time.

I notice that you create two factors controllers, but since you are using fortify, you can use their own: https://github.com/laravel/fortify/blob/1.x/routes/routes.php#L121-L134

And I would already use bootstrap 5 so you don't need jquery. It will be released in December as currently planned.

Oct
21
2 months ago
Activity icon

Replied to How To Modify Or Extends {{ }} Functionalities.

You could create a Blade directive.

In your App service provider register it like:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    // code commented for brevity

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Blade::directive('convert', function ($number) {
            return "<?php echo number_format($number, 2); ?>";
        });
    }
}

And then in blade use it:

@convert($var)

Check this package which has more examples:

https://github.com/appstract/laravel-blade-directives/blob/master/src/directives.php

Oct
20
2 months ago
Activity icon

Replied to Laravel 8 Forms Build Library

If you want something like laravel 8, with components, check this one https://github.com/protonemedia/laravel-form-components

It has support for bootstrap and tailwind, and livewire, binding and other helpers.

But if you are using jetstream then you can use their components see here https://github.com/laravel/jetstream/tree/1.x/resources/views/components

The package above offer more features.

Activity icon

Replied to Multi Auth With Roles And Permissions

Each auth has it's own Guard in Laravel when you setup multi auth.

Then in spatie you need to specify which guard name you want to use for that role or permission you create or check. See https://spatie.be/docs/laravel-permission/v3/basic-usage/multiple-guards

It's more simple to have just one auth and multiple roles/permissions that manage, and most probably is enough.

There are some package that can help you build multi auth skeleton in case you want go with it, see:

https://github.com/mtvbrianking/multi-auth

https://bitfumes.github.io/laravel-multiauth/

Oct
19
2 months ago
Activity icon

Replied to How To Build Ajax Registration And Login System In Laravel 8

With this vanilla js and axios you can process your login and register via ajax. Can and should be improved maybe instead of alert use some toast notifications. You could also display each single errors from server and/or add client side validation. In case you can also show validation errors appending after input. You don't need to change server code if you are using Laravel UI or Fortify. The response will be json when you make ajax request.

const formElement = document.querySelector('.js-ajax-form')

    formElement.addEventListener("submit", function (event) {
        event.preventDefault()

        const form = this

        const data = new FormData(form)
        const url = form.getAttribute('action')
        const method = form.getAttribute('method')

        axios({
            method: method,
            url: url,
            data: data,
            headers: {'Content-Type': 'multipart/form-data'}
        })

            .then(function (response) {
                
                alert('Successfully logged-in');

                // Reload page so you will be redirected to default page defined in Laravel
                window.location.reload()
            })

            .catch(function (error) {
                let message = 'An error occured.'; // Default error message

                if (typeof error.response !== 'undefined' && typeof error.response.data !== 'undefined') {
                    // Error message from server
                    if (typeof error.response.data.message !== 'undefined') 
                        message = error.response.data.message


                    // Access input errors using:

                    if (typeof error.response.data.errors !== 'undefined') {
                        let errors = error.response.data.errors
                        for (let input in errors) {
                            if (errors.hasOwnProperty(input)) {
                                //errors[input].join('<br/>')
                            }
                        }
                    }
                }
                alert(message);
            })
    })
Activity icon

Replied to Why Actions In Laravel 8?

I use also Spatie permissions package :) But I agree that it has unecessary features for my need (for avoid to use word abstractions :)... However, I refactor the Models of spatie permissions by removing guard and polymorphic relations, and using only constraint relation (users, roles, user_permissions, roles_permissions). I gain a bit in performance. Most of my package that I use are from spatie. And I customize a few to fit my need.

Oct
18
2 months ago
Activity icon

Replied to Why Actions In Laravel 8?

I'm glad we were able to understand each other.

From this I can see that you do not want to depend on packages and want to do as much is possible manually so you can have full control over it.

Yes but I don't want that you maybe misunderstand. I don't want that you think that I want re-invent the wheel. If I need a package, backend or frontend, I am more than happy to use it. But of course if I don't need it, then why I should keep it? Who want?

Now regarding your last questions regarding Livewire and Inertia. First about Livewire. Shortly, it's a good package for those who are not good with JS. It allow to create interactive page writing only PHP. But for a full stack developer who love frontend development like me, then is not solving any problem, rather is adding only new problem to solve. Many love concept of making interactive page without writing JS, and Caleb do good job delivering something that many need. But comparing it to original idea which it come from, which is Phoenix LiveView (https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html), Livewire is just ajax requests vs socket of Phenix LiveView. Totally two different world.

I make the same result of Jetstream with Fortify and now doing the same with Laravel UI, but even better since all page and forms (also auth forms) is loaded via ajax using axios and turbolinks. So the same interactive UI which aim to offer Livewire.

I also think that is still not mature project, but that is minor issue, considering it popularity it will become mature very soon. But at the current stage I would not use it in production.

Alpine has similar issue, I just don't like to put JS inside HTML and trying to get my head around how to solve something that I can quickly and more eleganty do with plain vanilla JS. There is another one which do similar things, https://htmx.org/ and it can be good for developers who can't work with JS.

In my opinion nowday developers must consider to learn also JS, and Livewire has potential to delay this if developer use it.

I could say more things specifically about Livewire that I found, but I think and hope you get my main points.

Inertia on other hand I like a bit more because you still write JS on frontend, and if you change backend, you can still use your frontend, while with Livewire you can't. If I have to choose between the two, then Inertia would be winner. But maybe I am a bit too conservative and still prefer old fashion with API on backend and routes via VueJS (my preferred).

Last thing not less important. I can't work with Tailwind. I really try but I can't. Maybe after so long time working with Bootstrap and other OOCSS I can't change my habit and switch to something so "low-level" to use Adam words. Maybe is only question of habit. I like the Adam TailwindUI, and I consider to use it, but for now I can do just with Bootstrap much faster what I can with tailwind. There are also several things that seem TailwindCSS can't solve. But that is another story.

Activity icon

Replied to Why Actions In Laravel 8?

Nope? In general both are first party packages that provide abstractions for problems they are solving.

We could now speculate with words, but I see Cashier solving 1 problem, extracting logic that can be re-used in several project. While a scaffolding, or boilerplate such as Jetstream doesn't solve 1 problem, has authentication, team, UI for 2 different frontend, etc. But taking into account your answer could be seen as the same.

So you are saying that Jetstream is an unnecessary abstraction and people should use laravel/ui instead if they do not plan to use Livewire/Inertia?

Seem that you finally get my point. Thanks God. I mean exactly that. IF they don't plan to use Livewire/Inertia BUT even if they plan to use Livewire or Inertia there is unecessary abstraction. Because they will use Livewire OR Inertia. Is necessary abstraction only if they use both.

So you are against it cause it makes you use Livewire or Inertia?

This will raise I think another discussion for another week, so I think is better for me to not comment this. It's that fine for you or you would like to hear my opinion regarding this?

Activity icon

Replied to Why Actions In Laravel 8?

@jlrdw I know that "secret". I am not sure to get your point. I am not saying anything against OOP or separation of code. Working with any MVC framework you are already forced to separate your code in very well manner. With Laravel you have also several others way to separate your logic (form requests, policies, middleware, service providers, resources, etc.).

@bugsysha if working with Laravel standard API is "procedural solution" then we have different view what is a procedural solution. Experienced developer make worry about abstraction when there is need to worry about abstractions. Where there is not, then keep it simple. The refactoring and abstraction stuff, ie polishing code, is something that I enjoy to do, is not something to fix, but rather something to improve. And what I see there is not a general abstraction right for any project, rather is something specific to application/project.

DRY in Jetstream is only to handle multiple frontend which I and most probably you and most of us will never need to manage. It's a solution dedicated to Jetstream. Is not a solution for any end application.

You can't compare Laravel Cashier with Jetstream, first is "an expressive, fluent interface to Stripe's subscription billing services." while second is "a beautifully designed application scaffolding for Laravel.".

Can you see difference?

Last, I am not saying Jetstream implementation is bad, but rather is not appropriate for common usage as what aim to be a "scaffolding application".

In my very first reply I didn't say "stay away from Jetstream, that is bad implementation", but I start with this word "I think that it depend on project that you are working.".

Activity icon

Awarded Best Reply on LV8 Jetstream /register: Set Default Value From Get-parameter

Inside component prop :value don't use {{ }}

 :value="old('code', request()->get('code'))"
Activity icon

Replied to LV8 Jetstream /register: Set Default Value From Get-parameter

Inside component prop :value don't use {{ }}

 :value="old('code', request()->get('code'))"
Activity icon

Replied to Why Actions In Laravel 8?

Point is that all apps tend to get bigger. So why postpone necessary?

I think that I implicit answer this questions in my 2 long answers after it. But for the sake of clarity, I will answer explicity.

I don't think that all apps tend to get bigger. I make for many customers web apps and mobile apps that simple remain as-is since first release, for years. Or they don't have cost for further development, or they close business for other reasons. Or they are happy with current stage. I have even my commercial social network application still running with PHP 5.x and PhalconPHP 1, still being used by several customers. Now nearly 2 years not updated apart minor fixes. Technology move fast, and I see that most of your application is more easy to refactor than upgrade to new one. This happen with an Angular 1 app, with several Ionic app, Phalcon PHP, and I think also for switching from Laravel 4 to 5.

I don't start a project thinking on abstractions immediately, I do that when in phase of polishing the code, when I see necessity of extraction of code. Refactoring is part of that process.

I think an inexperienced programmer starts thinking about abstractions at first, I used to do that too. But it is impossible to predict the evolution of the code unless you do a month of analysis with UML digrams and everything else. They raise development costs that customers are not happy to pay. I'm not saying they don't need to be done, on the contrary, in some projects they are essential. But in small to medium projects they are not. I prefer to keep the code as simple as possible at the beginning, even if that means repeating the code a few times. And only towards the end if I see the need I extract the code. But often this is not necessary.

Again, if you are large company working with many developers, then you may think differently. But being a solo developer or small team, you can't afford to work as a company.

Now, Jetstream/Fortify offer abstractions for handle 2 frontend, which I will never use. And this abstraction make code more complicated to manage. Something that I and other developers don't need make your starting point already complicated.

I hope that I did explain well myself.

May Jetstream be with you.

Oct
17
3 months ago
Activity icon

Replied to Why Actions In Laravel 8?

I've asked nicely but I've also tried to cut it short and avoid any conflict since as I said we have different standards.

Actually, you have not asked nothing :)

Quoting your message:

"@thewebartisan7 sorry since English is not my strong point I'm having really hard time understanding you. What you are saying is so confusing to me cause everything sounds inconsistent. You say one thing then the other."

No questions here :)

It's just that the way you write is confusing to me or maybe that is caused by my interpretation of what you are trying to say.

I agree that is a mix of two. English is not my primary language, but I think you are also making your own interpretation. Considering the belief that most of communication is body language, part is the tone of voice, and very small part is the actual words spoken, it's easy to get misunderstand via written communication such as this. It is said that about 10% is verbal, so we missed 90% of the communication. But try reading again, and see if you agree almost with Spatie quote. You can't disagre with that.

All best and may the Schwartz be with you.

It took me a while to understand where this sentence came from. But then I remembered... Spaceballs :) I like more the origin of this phrase, and is not "May the force be with you", but the original is "May the Lord be with you."

Bless

Oct
16
3 months ago
Activity icon

Replied to PSR-4 And Upgrading To Composer 2

For your Transaction package should be:

namespace Vendor\Transaction\Events;

If you are working for a company, then you can use as Vendor CompanyName or your name, or your project name, must be unique so that doesn't get in conflict with other vendor name.

SubNamespaceNames, in your case Transaction, MUST corresponds to at least one “base directory”. So in Transaction package the base directory is transaction, so is correct Transaction.

I suggest to read this page: https://www.php-fig.org/psr/psr-4/ is not long and has all specifications and examples.

Activity icon

Replied to PSR-4 And Upgrading To Composer 2

PSR-4 specification must have fully qualified class name in form:

<NamespaceName>(<SubNamespaceNames>)*<ClassName>

Your namespace missing a top-level namespace name, the vendor name.

Read full specification here: https://www.php-fig.org/psr/psr-4/

Activity icon

Replied to Livewire Components Rendor Method

With trait you have also somethinig like mount, like boot of eloquent model, see WithPagination, initalizeTraitName()

Activity icon

Replied to Livewire Components Rendor Method

I don't think you can return a component. But I would create a trait, something like trait Livewire\WithPagination where you add shared code between the two component.

So you have still 2 component, ClientsIndex and EmployesIndeex and one trait, example ResourceIndex, which you can include in both component, and both component return the same view.

Make sense?