Robstar

Member Since 5 Years Ago

Developer at F9 Web Ltd.

Experience Points 142,230
Experience Level 29

2,770 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 1242
Lessons
Completed
Best Reply Awards 27
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

20 Aug
1 day ago

Robstar left a reply on Urgent Whoops

If the framework is so pathetic why are you a member of a forum discussing the said framework. If Laravel is so pathetic no one is forcing you to use it.

13 Aug
1 week ago

Robstar left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

Whilst this doesn't help, this thread is actually pretty entertaining to read. Feel sorry for @snapey :)

Robstar left a reply on Laravel Queue Worker Stops After 15min If Started Via Task Schedule But Keeps Running If Started From CLI

With the greatests respect, this setup demonstrates one thing only. You urgently need to use a none shared host. AWS for example are dirt cheap.

The majority of shared hosts will not allow long running processes and daemons. I'm sure your host has something their end to automatically kill such processes.

Supervisord is exactly what shared hosts don't want you to be using as the queue worker for example is running permanently and always consuming resources. By definition, you're on a shared host.

Instead of trying all this, simply migrate to a server where you have control. You can setup a cheap AWS server within a 10 or 15 minutes (with ssl, queue worker, redis, databases, auto deployments etc.) using Laravel Forge.

Hell, the majority of shared hosts don't even have Git available.

Robstar left a reply on Urgent Whoops

I guess @pdc is looking for experience points. Not sure why anyone would reply to a thread 2 years old.

Robstar left a reply on How Good Of A Idea Is To Make A Status Table ?

This completely depends upon your use case and application size.

There are tons of options, all of which have their pros. and cons.:

  • Get static list status from a config file / helper method
  • Get status from the database on a per model basis i.e. post statuses, employee statuses
  • Create a generic status table that can be used by all models and applies to to the whole application
  • Store all statuses used application wide in a polymorphic table - avoids repetition in larger projects but does introduce additional logic to display statuses

Robstar left a reply on How To Fill This Array?

You've not provided enough code for us to answer your question.

On the face of it you have a disabled input. Try changing disabled to readonly.

Howeever, ultimately there will be some logic within your Vue component that sends the data to the server - that's the code you need to psot.

Robstar left a reply on How To Show 1 Job After Every 5 Posts In Vuejs Laravel?

@siangboon Amen to that. A lot of people put in zero effort and demonstrate no willing to learn themselves.

@raviawasti Going forwards you'll get faster and better quality answers if you demonstrate the fact you've tried something your end beforte posting.

Robstar left a reply on Problems With Making A New Project

That doesn't make sense. Your composer file has nothing to do with the server Cli version.

You have two options:

  • Lower the PHP requirements within your composer file, to match your server setup
  • UPgrade the cli version on the server to match that of your composer file

Robstar left a reply on Constructive Feedback Request -- Controller Method Optimization

As you've type hionted the request class anyway, you may aswell create a form request class. I personally think that validation done in controllers results in unecessary duplication.

For the toaster messages, that you mention you use in every controller you could create a RedirectResponse macro. This would allow you to create a toaster notifiucation and redirect using the following syntax:

return redirect()->route('employees.index')->created();

The macro itself need to go into a service provider (assuming the toaster class just sets flash data) i.e.

` RedirectResponse::macro('created', function ($route) { Toastr::success('Employee has been added.', 'Success!'); return $this->with('success', 'The record was created'); });

`

For the calculations, again they're fine in the controller ina small project. I personally move satuff like that to Eloquent observers, meaning you could remove lines 21 - 27 from the controller completely.

Robstar left a reply on Event Calendar For Laravel 4.0

This is a new error to your original question. Insteads of developing within Windows trying LaraDock or Homestead. You'll run intoi far less issues.

What is the content of your package.json fiile?

Robstar left a reply on How To Show 1 Job After Every 5 Posts In Vuejs Laravel?

whispering? eh?

I have provided the answer to your question. You appeart to be annoyed because it involves effort your end i.e. reading doicumentation. I'll comment and reply where I see fit, not where you state.

If you're not willing to research and read documentation you're not going to go very far in web development.

Robstar left a reply on Problems With Making A New Project

I'm a little undersure what the issue here, the error message you've posted literally states:

This package requires php ^7.1.3 but your PHP version (5.6.40) does not satisfy that requirement

That's very clear as to what the problem is.

Simply ensure the PHP Cli version matches the requirements defined in your composer file.

Robstar left a reply on How To Show 1 Job After Every 5 Posts In Vuejs Laravel?

If you haven;t tried anything yet hhow are we suppossed to help you? If you want people to complete tasks for you it sounds like to need to purchase the time of a developer.

You should take time to understand the basics of Vue, as it's very powerful. For example, have you read https://vuejs.org/v2/guide/list.html ?

Robstar left a reply on Event Calendar For Laravel 4.0

The Laravel Fuillcalendar package is basically just a transformer for your Eloquent queries. If you have a look at the package source code (which is very small and easdy to follow) you'd be able to see what it's doing.

I think you're looking at Laravel badly imo. Instead of thinking, "I need to use the full cal package on my site, the only only way I can do this is to Google for a specific Laravel package". If there are no Laravel specifci packages you're, or the packages don't do exactly what you want your stuck.

Take time to understand the package you're using and Laravel. Laravel (like an PHP framework) can integrate with full cal. If you take time to read the full cal docs (which you haven't in this case) you'd note the package has the concept of event sources. One of these sources is a JSON feed (see https://fullcalendar.io/docs/events-json-feed).

So to answer your question, you'd create an API endpoihnt to return the events in the format the full cal packages expects (Laravel resourcxes are excellent for this - https://laravel.com/docs/5.8/eloquent-resources) and then use that as your event source.

Failing that, you could have forked or submitted a pull request to the Laravel Full Cal package yourself and made the changes your end.

If you just try and Google for the answer to any given situation you'll never understand or be able to make the most of the packages you're using.

12 Aug
1 week ago

Robstar left a reply on Sharing Users Between Multiple Laravel Projects

An API to handle all the auth. imo.

01 Aug
2 weeks ago

Robstar left a reply on Calculate Price With Checkbox

@hjortur17 I'd strongly recommend you go ahead and read about the Vue Dev tools plugin. THis will help with spotting bread and butter errors like this.

Robstar left a reply on Count New Users In Daily, Weekly, Monthly Using Laravel And Vue.js

The simplist method is:

setTimeout(this.countuser, 5000);

There's an example at https://gist.github.com/Hammer2900/8e59f6d378a8afab3c1d9b514f84752c

There's an old example made by the Vue author at https://jsfiddle.net/yyx990803/xpe9r6wa/2/ - the ready event is now created I believe. It's quite an interesting idea as he uses the timestamp as a computed property i.e. when the current timestamp (however you wish to formnat that) changes, your component updates.

Re formatting, if you using the stats in a single place, then have it as single component. If you're using them elsehwhere and need control of how they appear visually, I'd recommend creating a renderless component.

Robstar left a reply on Display .md File With Javascript

The Vue website has a very simple example using the 'marked' package: https://vuejs.org/v2/examples/index.html

23 Jul
4 weeks ago

Robstar left a reply on Charge An User Every 30 Days. (job/queue)

@zfdeveloper With the greatest respect, have a read about the basics of commands, jobs and the difference between them. I belive there videos on this site covering the topic too.

18 Jul
1 month ago

Robstar left a reply on Need A Database Advise

If you have shared pages, then go for the second option. The second option avoids duplicating pages.

i.e. page id 1 could be used by departments id 2, 3 and 4.

Robstar left a reply on DataTables Glitch?

You're going to need to give more information than this and priovide your code to get any decent answers.

Robstar left a reply on RESTful API And Web

Yes, you'll notice Laravel has two route definition files for that i.e. web.php and api.php, where you definite web and api routes respectivly. The API routes, by default, have different middleware.

This allows you have an internal api, split from the web app.

Robstar left a reply on Homestead Mapping Folders

Have never used Apache with Homestead, but the Laravel documentation at https://laravel.com/docs/master/homestead#adding-additional-sites suggests:

- map: c:/Users/<username>/projects/sa
      to: /var/www/sa
      type: "apache"

You've missed that from your code.

Robstar left a reply on How To Add Confirmation Details Page Before Form Submitting?

What have you tried so far. Please show us your current code.

Robstar left a reply on Need A Database Advise

Definately do not create a separate table for each department or create a table per page! :)

departments
- id
- title

contents
- id
- department_id
- content (ie. some html)

The above will work if you do not wish to share content between departments.

If you have some form of content repository / store, where is makes sense to share this between departments, then the following would make more sense:

departments
- id
- title

contents
- id
- content (ie. some html)

department_contens
- deparment_id
- content_id

This is all really bread and butter stuff. I'd recommend before writing applications you read up on database design to get the basis down.

17 Jul
1 month ago

Robstar left a reply on Calendar Widget In Laravel

No 'widget' of such, you'll need to write some code yourself.

Use something like https://fullcalendar.io to display your events. Your event source could be a simple API endpoint written in Laravel.

People really should get out of the 'how to do this in Laravel' mindset. Laravel is PHP.

Robstar left a reply on Ignore Composite Key With Validation Rules

There are a lot of other options built in for the unique rule, see https://laravel.com/docs/5.8/validation#rule-unique

You could also write your own Rule class - https://laravel.com/docs/5.8/validation#using-rule-objects

Robstar left a reply on Laracasts Test Dummy Without Laravel

By "test dummy" are you referring to the base Laravel TestCase class?

15 Jul
1 month ago

Robstar left a reply on Form Request Validation For JSON Parameter

All that code would be much neater and more reusable in a rule class as described earlier.

Robstar left a reply on Form Request Validation For JSON Parameter

Then don;t use the built in rule.

Use a custom rule that firstly validates if the request item is json and then validates the structure.

Robstar left a reply on How To Save Data From One Form Into Different Db Tables

Lol at this entire thread. I'm checking out :)

Robstar left a reply on Form Request Validation For JSON Parameter

Well to validate if the data JSON, as in your OP, the Laravel docs have you covered. See https://laravel.com/docs/5.8/validation#rule-json

If you want the verify the exact JSON structure you'll need your own rule. The rule is a simple class that can accept any arguements as required i.e.

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class ValidJsonStructure implements Rule
{
    // @todo you expected structure as an array
    protected $expectedStructure = [];
    
    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value): bool
    {
        // $value is json string and can be manipulated on any way
        // would recommend you can convert the JSON string to an array
        // then return based upon if the actual array structure matches
        // $this->expectedStructure;
        // return true or false to validate 
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message(): String
    {
        return 'The :attribute must have the exact, expected, JSON structure';
    }
}

Then if your Form request:

...

'json_data' => [
            'required',
            'json',
            new ValidJsonStructure,
        ],
...

Robstar left a reply on What To Put In Model Observers

Another example - generating an API token when creating a user:

namespace App\Observers;

use App\Models\User;
use Illuminate\Support\Str;
user App\Traits\GeneratesUniqueStrings;

class UserObserver
{
   use GeneratesApiTokens;

    /**
     * @param User $user
     * @return void
     */
    public function creating(User $user): void
    {
        $user->api_token = $this->generateUnqiueToken('users', 'api_token');
    }
}

Robstar left a reply on Call Controller Function From Another Controller

Why does it have to be a controller? Why can't your logic be stored in a generic service class, that can be instantiated and called from anywhere.

Laravel gives you lots of other other options too i.e. event, jobs, model oberservers etc.

Robstar left a reply on [Homestead] Only Showing Contents Of Last Site In Yaml

Always read the documentation. https://laravel.com/docs/5.8/homestead#adding-additional-sites

It's been like this for a long time, at least since Laravel 5.3/5.4.

Robstar left a reply on Caching A Specific Column In Relationship?

@oliverbusk Yep, assuming stream->token is just a fixed database column. You could cache method call on a per request basis using a memorization function i.e. https://github.com/spatie/once

Robstar left a reply on Caching A Specific Column In Relationship?

Can't you just store the path segement in the datbase? Whhen the relationship updates, update the path too.

08 Jul
1 month ago

Robstar left a reply on Object Of Class Illuminate\Auth\AuthManager Could Not Be Converted To String

To state the obvious are you logged in?

What is the output of

dd( auth()->user() );

Robstar left a reply on How To Correctly Deploy Laravel Project ?

Well a 500 error is extremely general, at least give us something to go off.

For example, post some relevant lines form your chosen log stack.

If you ask better questions, you always get better answers.

Robstar left a reply on How Can I Create A Cms With Larave?

@maa Store just the basic article HTML text in your database.

https://pyrocms.com is also pretty nice to work with. My clients love the admin area too, which is a huge consdideration when choosing a CMS.

If you're just creating a personal article site I'd recommend something simler like https://jigsaw.tighten.co.

Robstar left a reply on Vuejs Relationship Is Working In Blade But Not On Vuejs

Use Vue dev tools and look at the data you've passed to your component?

How are you passing the data to your component? i.e.

<example-component :some-prop='@json($array)'></example-component>

You'll need to impriove your question (see https://stackoverflow.com/help/how-to-ask) if you wish to get a resolution.

Robstar left a reply on How To Correctly Deploy Laravel Project ?

"i get this error This page isnt working HTTP ERROR 500"

With the greatest respect you're very unlikely to get any resolution here with should a vague error and poor question.

I'd recommend you read https://stackoverflow.com/help/how-to-ask and post again.

02 Jul
1 month ago

Robstar left a reply on The Current User Is Not Authenticated PHPUnit

@BROWNIECOFFEE - Ah sorry, I had a custom factory state setup, you can just remove the chainedc all state.

01 Jul
1 month ago

Robstar left a reply on The Current User Is Not Authenticated PHPUnit

I'm running tests without issue, without disbaling middleware, i.,e.

` $user = factory(User::class)->state('active')->create([ 'password' => $password = '123', ]);

    $response = $this->from('/login')->post('/login', [
        'email'    => $user->email,
        'password' => $password,
    ]);

    $response->assertRedirect('dashboard');
    $response->assertSessionHasNoErrors();

`

Robstar left a reply on Query Scope Based On Multiple Conditions

@LIAMMCARTHUR - You could refactor that further to use the conditional when Eloqurnt clause, see https://laravel.com/docs/5.8/queries#conditional-clauses

25 Jun
1 month ago

Robstar left a reply on How Do I Handle Multiple Submit Buttons In A Single Form With Laravel?

@BABONDAY - People really need to get out of the "Laravel" way mindset. Laravel is PHP. I'm a little unclear on why you think Laracasts is pushing something other than PHP. If you think like this I;d recommend you go and learn the basics of PHP so Laravel makes more sense.

There is no need to "spend ages looking for the new magic way" as Laravel has excellent documentation.