aurawindsurfing

Laravel Newbie at @

Member Since 4 Years Ago

Dublin, Ireland

Experience Points
225,580
Total
Experience

4,420 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
1143
Lessons
Completed
Best Reply Awards
150
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 46
225,580 XP
Mar
04
2 days ago
Activity icon

Replied to Writing Query Inside Map

@deekshith I saw your question this morning. When you look at it it is a monnster query that only waits to break ;-)

Try moving your counts to relations first:

$catcorrectCount = UserAnswer::join('questions','user_answers.question_id','=','questions.question_id')->where('questions.test_id',$test_id)->where('questions.language',$user_tests_det->test_language)->where('user_answers.user_test_id',$user_test_id)->where('questions.question_category',$category->question_category_id)->whereRaw('user_answers.user_answer = questions.correct_option')->count();

Should become just:

UserAnswer::catcorrect()->count();

That would be a good start for me.

Activity icon

Replied to Change Connection Right After Login

Hey @johnw65

What how do you connect to your oracle database in first place? How do you establish that you actually have a connection?

Activity icon

Replied to How To Access The Relationships Via Models In Laravel 8 Inertia

@samar92 You need to show more of your code, please.

Do you call this in a vue component? I so you should fetch all the data before passing it to vue, so in your controller.

Activity icon

Replied to Info Frontend / Backend / Api Structure

@yohannes81

I feel your pain as you try to make sense of all of it ;-)

Ok one by one:

  1. What is front end - this is what users see and interact with. It should hold no logic and only display data to users and get data from users.

  2. What is backed? It is something like an admin panel where you do "stuff" with what users expect you to do eg. moderate, generate etc.

  3. Your code. Now this is where magic happens. The code you write will in the end generate frontend, generate your backend if needed and also handle API.

  4. Ok so what is API then? Well, imagine it is a front end but without all those nice html and css. In fact if you go to any of the functions in your app and at the end instead of

return view('welcome');

you do this or any other data you want:

return User::all();

You will get proper json response which is exactly what you expect from API.

5 Address of the backend - everyone can know it. You just secure it with something like Laravel Fortify.

6 File storage - look at answer 3.

7 S3 - nothing to do with any of it. You can use it or not, it has nothing to do with mobile apps or your app.

Hope that points you in the right direction!

Activity icon

Replied to How To Code For Validating Multiple Data With Similar Parameter In Compact Way For Laravel API?

Hey @nikunj001

The only ok way I saw to do this was to decode json to array and then validate the data. There is no nice "laravel" way to do it straight away with json as far as I'm aware.

Activity icon

Replied to How To Display Data On Edit Livewire One Modal CRUD

@anonymouse703 so you are using livewire with vuejs as a front end right?

The answer will be you do it exactly the same as with alpinejs:

https://laravel-livewire.com/docs/2.x/alpine-js

Feb
22
1 week ago
Activity icon

Replied to View Website Using IP Address In Forge

@peterdickins did you ever checked cloudflare? You can register your domain there and then let cloudflare handle all of your dns stuff. The beauty of it is that any change to IP will be more less visible immediately everywhere in the world.

Oh and it is free for basic usage ;-)

Enjoy!

Activity icon

Replied to All Jquery Resources Are Ok But Dropdown Doesn't Work

You need to import that .js into your app.blade.php in order to work.

Or mix it in with Laravel Mix

Feb
16
2 weeks ago
Activity icon

Replied to Date Casting In Query

Hi @bradycharron

In your model use:

protected $casts = [
        'min_date' => 'date',
    ];

instead of:

protected $casts = [
        'min_date' => 'datetime',
    ];
Activity icon

Replied to Dynamic Component Name

@azzie great find!

Feb
05
1 month ago
Activity icon

Awarded Best Reply on Need To Track And Monitor Oracle DB Connection

@johnw65 Laravel can work with Oracle but it is not as straight forward as it might seem.

Oracle instance has users table but to use this credentials to log into you web app is will be quite tricky as you have to know what hashing mechanism was used and etc.

It will be much simpler to use emails of users and generate passwords for them.

Why your uses have direct access to database anyway?

Feb
01
1 month ago
Activity icon

Awarded Best Reply on Session Timeout - Alert User

@johnw65 if session expires then next refresh will redirect to login page. This is how it works. You could in theory show a timer to the user by checking his session when he enters/refreshes the website.

But the question is: "Why bother doing it?"

If you really have to do it then set session lifetime to some crazy value in config/session.php:

'lifetime' => env('SESSION_LIFETIME', 120),

525600 would be a year.

Jan
28
1 month ago
Activity icon

Replied to Livewire Telephone Input

Hey @joeseph chen

I use this package for my phone dilemmas: https://github.com/Propaganistas/Laravel-Phone

It also has validation helper so you could validate your phone using it and livewire validation logic.

I'm not too sure if you even need to use alpinejs in that case, you can skip the whole country selection to be honest, just validate like this:

$m->to = PhoneNumber::make($a->user->phone, ['UK', 'DE', 'FR'])->formatE164();

It works quite well for me.

Activity icon

Replied to Setting Correct Value In Mail Settings To Send Email Using Smtp Server

Hey @enthusiast14

An easy way to test if your emails are working is to use this app:

https://usehelo.com/

It has its own email settings that can be easily implemented. This way you will check if your app actually works and sends emails.

Then when you have that verified, switch it with your smtp credentials. This should get you on the right track.

Jan
26
1 month ago
Activity icon

Replied to AssertDatabaseHas But Within A Field Contains A Value

@cleverouge

Try this:

$this->assertContains($value, $array);
Activity icon

Replied to Www Prefix On Subdomain

Hey @lasota

You could use build in forge redirects but this is not the correct way to handle this.

You should use your DNS records to do this. I use Cloudflare for it and it should look like this:

CNAME record for www.subdomain pointing to subdomain.domain.com

A record for subdomain.domain.com pointing to your forge IP.

Hope it helps!

PS. I'm not too sure about this part: www.subdomain or fullwww.subdomain.domain.com for CNAME, it works just for www for TLD

Activity icon

Replied to Darkmode Flickering

Did you just discover alpinejs? ;-)

Activity icon

Awarded Best Reply on Darkmode Flickering

@troj

Have a look how alpinejs deals with it:

https://github.com/alpinejs/alpine#x-cloak

It is due to you changing property of a DOM element after it is being loaded. With cloak you apply all changes to it and only after everything is done, you display it. This removes flickering.

Hope it helps!

Activity icon

Replied to Unable To Get JSON Response Via Web Hooks API.

@bipin_1611 did you ever hear about Postman? Have a look at this link:

https://developer.squareup.com/docs/testing/postman

First set up your postman, then download squareup collection (all of the API endpoints already configured), then test it with postman so you are sure everything works as expected, then transfer that to Laravel.

It is much easier to troubleshoot that way.

Also the easiest way to access API in laravel is to use Http client:

https://laravel.com/docs/master/http-client#request-data

use Illuminate\Support\Facades\Http;

$response = Http::post('http://example.com/users', [
    'name' => 'Steve',
    'role' => 'Network Administrator',
]);

and then your json will be here:

$response->json();

Hope it helps!

Activity icon

Replied to Laravel Redirection To Email/verify With SSL

@adamantyn Can you show the contents of that file?

Activity icon

Replied to Darkmode Flickering

@troj so thats the the same principle right?

Jan
25
1 month ago
Activity icon

Awarded Best Reply on [InvalidArgumentException] Package Digikraaft/laravel-paystack-subscription Has A PHP Requirement Incompatible With Your PHP Version, PHP Extensions And Composer Version

Have a look at this file: https://github.com/digikraaft/laravel-paystack-subscription/blob/v1.0.0/composer.json

This is the "oldest" file he has but it is from June 2020 so this package was developed only for Laravel 7 and lately updated to Laravel 8. It says it all in the file:

 "require": {
        "php": "^7.4",
        "ext-json": "^7.4",
        "digikraaft/paystack-php": "^1.0",
        "dompdf/dompdf": "^0.8.5",
        "guzzlehttp/guzzle": "^6.5",
        "illuminate/contracts": "^7.15",
        "illuminate/database": "^7.15",
        "illuminate/http": "^7.15",
        "illuminate/notifications": "^7.15",
        "illuminate/routing": "^7.15",
        "illuminate/support": "^7.15",
        "illuminate/view": "^7.15",
        "nesbot/carbon": "^2.35",
        "symfony/http-kernel": "^5.1"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^2.16",
        "orchestra/testbench": "^5.0",
        "phpunit/phpunit": "^9.0",
        "psalm/plugin-laravel": "^1.2",
        "vimeo/psalm": "^3.11"
    },
  1. So you are still using older version of php.

  2. You do not have ext-json installed

  3. Update your composer to version 2

Hope it helps!

Activity icon

Replied to Session Timeout - Alert User

@johnw65 if session expires then next refresh will redirect to login page. This is how it works. You could in theory show a timer to the user by checking his session when he enters/refreshes the website.

But the question is: "Why bother doing it?"

If you really have to do it then set session lifetime to some crazy value in config/session.php:

'lifetime' => env('SESSION_LIFETIME', 120),

525600 would be a year.

Activity icon

Replied to [InvalidArgumentException] Package Digikraaft/laravel-paystack-subscription Has A PHP Requirement Incompatible With Your PHP Version, PHP Extensions And Composer Version

Have a look at this file: https://github.com/digikraaft/laravel-paystack-subscription/blob/v1.0.0/composer.json

This is the "oldest" file he has but it is from June 2020 so this package was developed only for Laravel 7 and lately updated to Laravel 8. It says it all in the file:

 "require": {
        "php": "^7.4",
        "ext-json": "^7.4",
        "digikraaft/paystack-php": "^1.0",
        "dompdf/dompdf": "^0.8.5",
        "guzzlehttp/guzzle": "^6.5",
        "illuminate/contracts": "^7.15",
        "illuminate/database": "^7.15",
        "illuminate/http": "^7.15",
        "illuminate/notifications": "^7.15",
        "illuminate/routing": "^7.15",
        "illuminate/support": "^7.15",
        "illuminate/view": "^7.15",
        "nesbot/carbon": "^2.35",
        "symfony/http-kernel": "^5.1"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^2.16",
        "orchestra/testbench": "^5.0",
        "phpunit/phpunit": "^9.0",
        "psalm/plugin-laravel": "^1.2",
        "vimeo/psalm": "^3.11"
    },
  1. So you are still using older version of php.

  2. You do not have ext-json installed

  3. Update your composer to version 2

Hope it helps!

Activity icon

Replied to Dashboard Display Content Depending On User Type

@malbe This is what you are looking for: https://laravel.com/docs/master/authorization

Please note that Authentication <> Authorization

You can be authenticated to use app but not authorised to see some content eg. part of your dashboard.

Hope it helps!

Activity icon

Replied to Darkmode Flickering

@troj

Have a look how alpinejs deals with it:

https://github.com/alpinejs/alpine#x-cloak

It is due to you changing property of a DOM element after it is being loaded. With cloak you apply all changes to it and only after everything is done, you display it. This removes flickering.

Hope it helps!

Activity icon

Replied to Laravel Redirection To Email/verify With SSL

@adamantyn Whats the version of your app?

Do you have this class in your app?

App\Http\Controllers\Auth\LoginController.php
Jan
22
1 month ago
Activity icon

Replied to Laravel Redirection To Email/verify With SSL

Hey @adamantyn

First thing I notice is this:

public function boot()
{
  /* Force SSL routes */
  if($this->app->environment('production')) {
    \URL::forceScheme('https');
  }
}

No need for that either if you use forge it will automatically redirect to https when you generate your cert, if you use cloudflare - the same thing. No need to have it in your code.

Second thing I notice is that you do not need this:

Route::group(['middleware' => 'web'], function () {

This is what the documentation says:

Out of the box, Laravel comes with web and api middleware groups that contain common middleware you may want to apply to your web and API routes. Remember, these middleware group are automatically applied by your application's App\Providers\RouteServiceProvider service provider to routes within your corresponding web and api route files

And the last one:

 Route::middleware('verified')->group(function () {
    /* Route for the Home page */
    Route::get('/', '[email protected]')->name('welcome');

You are telling your app to redirect visitor to be verified before he can access '/' This is why your app redirects to :

https://example.com/email/verify 
Jan
21
1 month ago
Activity icon

Awarded Best Reply on Formatting Data For Charts

@uniqueginun first generate all the dates that you need, then replace the ones that actually have values in that array. This way you will have complete array with values where they exist.

Activity icon

Replied to Formatting Data For Charts

@uniqueginun first generate all the dates that you need, then replace the ones that actually have values in that array. This way you will have complete array with values where they exist.

Activity icon

Replied to How To Keep Selected Value In Dropdown After Submit In Laravel

<option value="pending">Pending</option>
Activity icon

Replied to Too Many Redirects On Localhost

Obviously you have created a loop. A very good way to diagnose this would be to use this new debugger:

https://myray.app/

It will show you all requests one my one if you put it in the AppServiceProvider.

Activity icon

Awarded Best Reply on Livewire Maths - Calculate A Live Total

Each time you will update wire:model it will call render() method in livewire component. So just put your calculation in there and it will update each time you update variables.

public function render()
    {
	$this->result = $var1 + $var2 + $var3;
        return view('foo');
    }

Store the result in public property on your livewire component, those properties are the available in the view like this:

public $var1;
public var2;
public var3;
public $result;

in the view:

{{$result}}
Activity icon

Replied to Livewire Maths - Calculate A Live Total

Each time you will update wire:model it will call render() method in livewire component. So just put your calculation in there and it will update each time you update variables.

public function render()
    {
	$this->result = $var1 + $var2 + $var3;
        return view('foo');
    }

Store the result in public property on your livewire component, those properties are the available in the view like this:

public $var1;
public var2;
public var3;
public $result;

in the view:

{{$result}}
Activity icon

Replied to Image Intervention: Can't Write Image Data To Path

@marinario I have been confused by this issue so many times. I have this in one of my apps and it works:

$imgResize->save('public/'.$filename));

So when you do

'public'

it will default to

'storage/app/public/'

Try if it works.

Activity icon

Replied to Image Intervention: Can't Write Image Data To Path

Hey @marinario

Its issue that pops up every so often.

First check if you did php artisan storage:link

Second double check your paths, there must be a mistake in there.

I also had this issue with using valet secure when the local link was https but I was trying to save to http path

Activity icon

Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

@bgass does your counter increment on every self refresh of the page?

public function render() {
		$this->get_tool();

		$this->renderCount++;
		return view( 'livewire.toolbox' );
	}

It looks like it should if it is livewire which is refreshing your page.

Jan
20
1 month ago
Activity icon

Replied to Admin Send Messages To Users

@snapey excellent find!

Activity icon

Replied to Laravel + Docker + Windows

No. Sail works well with WSL2 its in the docs.

Activity icon

Replied to Prevent Livewire To Constantly Refresh Page, But Still Update Data Values

If Livewire loops usually it is due to not knowing to which element it should relate. Try adding wire:key to your div. Have a look here: https://laravel-livewire.com/docs/2.x/troubleshooting

So in your case:

<div wire:key="foo">
	<input autofocus type="search"
		   wire:key="bar"
		   wire:model.debounce.500ms="input_value"
		   placeholder="Entrer un code..."
		   class="border rounded p-3 focus:outline-none focus:shadow-outline-blue w-full" >
	
	<p>Counts: {{ $renderCount }}</p>
	<div>
		@includeIf($current_page)
	</div>
	
</div>

And see it it helps

Activity icon

Replied to Admin Send Messages To Users

It depends how you imagine this functionality to work.

The simplest Idea I have is simply using Cache. You can store it forever you can store it for some time and then display to the user if it exists.

https://laravel.com/docs/master/cache#storing-items-in-the-cache

Having said that this is probably too simple to be true.

Other then that you could use database table and mark if user read the announcement etc.

There are probably many more ways to do it.

Jan
19
1 month ago
Activity icon

Replied to Bootstrap Tab And Search Bar

Yes you do not need any bootstrap at all!