assoft

Member Since 5 Years Ago

Experience Points
17,125
Total
Experience

2,875 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
151
Lessons
Completed
Best Reply Awards
4
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 4
17,125 XP
Dec
17
4 weeks ago
Activity icon

Awarded Best Reply on Laravel Ajax File Upload

$fileName = time().'_'.request()->file("blog_resim")->getClientOriginalName();
$filePath = request()->file('blog_resim')->storeAs('uploads', $fileName, 'public');

$blog = new Blog();
$blog->url = '/storage/' . $filePath;
// ...
$blog->save();
Dec
16
1 month ago
Activity icon

Replied to Laravel Ajax File Upload

$fileName = time().'_'.request()->file("blog_resim")->getClientOriginalName();
$filePath = request()->file('blog_resim')->storeAs('uploads', $fileName, 'public');

$blog = new Blog();
$blog->url = '/storage/' . $filePath;
// ...
$blog->save();
Activity icon

Replied to Validation Required Field Error After Resetting The Properties

Honestly, I didn't come across anything related to this in the documentation. Maybe I'm getting old :)

So you want to tell me that this method performs a validation?

public function rules()
{
    return [
        'current_password' => ['required', 'string'],
        'new_password' => $this->passwordRules(),
    ];
}

Note: Please excuse my grammar mistakes!

Activity icon

Replied to Validation Required Field Error After Resetting The Properties

You should examine the document more carefully. Livewire uses the $this->validation() method for validation!

And this is not real time validation!

public function updatePassword ()
{
    $this->validate();
    // ...
}

If you need a real time validation, you use the updated hook!

Real time validation

class ContactForm extends Component
{
    public $name;
    public $email;

    protected $rules = [
        'name' => 'required|min:6',
        'email' => 'required|email',
    ];

    // Real Time Validation
    public function updated($propertyName)
    {
        $this->validateOnly($propertyName);
    }

    public function saveContact()
    {
        $validatedData = $this->validate();

        Contact::create($validatedData);
    }
}
Activity icon

Replied to Laravel Ajax File Upload

Try this;

let formData = new FormData();           

formData.append("kategori_id", $('#kategori_id').val()),
formData.append("blog_baslik", $('#blog_baslik').val()),
formData.append("blog_icerik", $('#blog_icerik').val()),
formData.append("blog_resim", $('#blog_resim').files[0]);
formData.append("blog_meta_title", $('#blog_meta_title').val()),
formData.append("blog_meta_desc", $('#blog_meta_desc').val())

$.ajax({
    url: "{‌{ route('blog.store') }}",
    method: 'post',
    data: formData
    // ...
})
Dec
15
1 month ago
Activity icon

Replied to Validation Required Field Error After Resetting The Properties

First, check the official documentation.

https://laravel-livewire.com/docs/2.x/input-validation

And remove this function!

public function rules()
    {
        return[

            'current_password' => ['required', 'string'],
            'new_password' => $this->passwordRules(),
        ];
    }

Add the rule:

class YourComponent extends Component {

    // ...

    protected $rules = [
        'current_password' => 'required|min:6',
        'new_password' => 'required|min:6',
    ];


    public function updatePassword ()
    {
	$this->validate();
	// ...
     }
}

Did help you?

Dec
14
1 month ago
Dec
12
1 month ago
Activity icon

Replied to Best Non-official Packages?

You can use all the packages of Spatie with peace of mind.

https://github.com/spatie

Dec
10
1 month ago
Activity icon

Replied to Quit Laravel

These have nothing to do with Laravel or Laracast or Jeffrey Way. This is directly related to you.

And I wish you success for your career.

Activity icon

Replied to How To Make "draft" Feature?

I am sorry that I do not have enough English language knowledge.

For this reason, I may not fully understand you or express myself fully.

It could be better this way:

Note: The request and table fields are representative. You should arrange it for yourself

public function index() {
    $posts = Post::orderByDesc('created_at')
        ->when(request()->has('status'), function($query) {
            $query->where("is_draft", request()->status)
        ->when(request()->has('published'), function($query) {
            $query->whereNotNull("published_at")
        })->when(request()->has('tags'), function($query) {
            $query->whereHas(["tags" => function($query) {
                $query->whereIn("tag_name", request()->tags)
            }]);
        })->paginate(13);
    
    return view('posts.index', ['posts' => $post]);
}
Activity icon

Replied to How To Make "draft" Feature?

Is this what you're looking for?

public function index($status = false, $published = false) {
    return Post::orderByDesc('created_at')
        ->when($status, function($query) use ($status) {
            $query->where("is_draft", $status)
        })->when($published, function($query) {
            $query->whereNotNull("published_at")
        })->get()
}
Dec
09
1 month ago
Activity icon

Replied to How To Make "draft" Feature?

Assign statuses to Eloquent models

Imagine you want to have an Eloquent model hold a status. It's easily solved by just adding a status field to that model and be done with it. But in case you need a history of status changes or need to store some extra info on why a status changed, just adding a single field won't cut it.

https://github.com/spatie/laravel-model-status

Activity icon

Replied to Livewire Components - How To Pass Flash Message From Child To Parent

Scoping To Parent Listeners

When dealing with nested components, sometimes you may only want to emit events to parents and not children or sibling components.

In these cases, you can use the emitUp feature:

$this->emitUp('postAdded');
<button wire:click="$emitUp('postAdded')">

Parent component

protected $listeners = ['postAdded' => 'incrementPostCount'];

public function incrementPostCount()
{
    $this->postCount = Post::count();
}

https://laravel-livewire.com/docs/2.x/events#event-listeners

Sharing State Between Livewire And Alpine: @entangle:

https://laravel-livewire.com/docs/2.x/alpine-js#extracting-blade-components

Did it help you?

Activity icon

Replied to Request A Externe Api

    $array = (array)json_decode($response->body());

    $xml = ArrayToXml::convert($array, 'config', true, 'UTF-8');
Activity icon

Replied to Request A Externe Api

Requirements

https://laravel.com/docs/8.x/http-client

composer require guzzlehttp/guzzle

SampleController.php

use Illuminate\Support\Facades\Http;

public function testApiMethod($id) {
    $response = Http::get("https://test.io/test/id={$id}&content=true");
    return response()->json($response->json(), 200);
}

routes/api.php

Route::get('/test/{id}', [SampleController::class, 'testApiMethod']);

Send get request your app: http://127.0.0.1:8000/api/test/1

Another sample:

routes/api.php

Route::get('test/{id}', function ($id) {
    $response = Http::get("https://jsonplaceholder.typicode.com/posts/$id");
    return response()->json($response->json(), 200);
});

request uri: http://127.0.0.1:8000/api/test/10

return

{
    "userId": 1,
    "id": 2,
    "title": "qui est esse",
    "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}

aaaaaand i'm done :) Good luck buddy.

Activity icon

Replied to Request A Externe Api

Please show me your code

Activity icon

Replied to Request A Externe Api

You must enter your application's url whatever.

http://127.0.0.1:8000/api/get-xml

i recommend it you review to Laravel Documentation. https://laravel.com/docs/8.x/routing

and https://laracasts.com/series/laravel-6-from-scratch/episodes/5

and Creating a Laravel API: https://www.youtube.com/watch?v=mgdMeXkviy8&t=728s

Activity icon

Replied to Request A Externe Api

Yes, but you must send a request to the full url address.

http://localhost:8000/api/get-xml or http://your-app-url/api/get-xml

Activity icon

Replied to Request A Externe Api

routes/api.php

Route::post("get-xml", [ApiController::class, 'getXML']);

ApiController.php


public function getXML(Request $request) 
{
    $result = ArrayToXml::convert($request->my_array, 'config', true, 'UTF-8');

    return response($result)->header('Content-Type', 'text/xml');
}
Activity icon

Replied to How To Display A Value In The First Column Of A Generated Table?

There is no any principle in this code.

Already using Eloquent queries in Blade ... creates the N + 1 problem.

It should not be like this!

There are dozens of courses on this site, I recommend you to take advantage of them.

Activity icon

Replied to Get Request Extrene Api In Laravel

Assuming you are using Valet;

  1. Open postman
  2. Create new request
  3. Set request type (get, post, etc..)
  4. Set request url: http://your-app.test/api/my-custom-api-url

Note: Sure it's open to the public

If you want to send a request to an authorized backend, you need to use auth middleware.

Sanctum Documentation; https://laravel.com/docs/8.x/sanctum

Sanctum Tutorial: https://laracasts.com/series/whats-new-in-laravel-7/episodes/6

sample:

Route::get('my-custom-api-url', function(Request $request, Configuration $configuration){
	return response()->json([
		"message" => "success",
		"request" => $request->all(),
		"configuration" => $configuration
	], 200);
})->middleware("auth");

In this case, you will prevent unauthorized requests.

Did this help you?

Activity icon

Awarded Best Reply on Get Request Extrene Api In Laravel

routes/api.php

Route::get('my-custom-api-url', function(Request $request, Configuration $configuration){
	return response()->json([
		"message" => "success",
		"request" => $request->all(),
		"configuration" => $configuration
	], 200);
});

Activity icon

Replied to Get Request Extrene Api In Laravel

routes/api.php

Route::get('my-custom-api-url', function(Request $request, Configuration $configuration){
	return response()->json([
		"message" => "success",
		"request" => $request->all(),
		"configuration" => $configuration
	], 200);
});

Nov
19
1 month ago
Activity icon

Replied to Livewire Trying To Get Property 'name' Of Non-object

Because you generate the $user object twice!

Try it...

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\User;

class UpdateUser extends Component
{
    public $userId;
    // public $user;     // Remove or comment this line

   ...
}
Nov
18
1 month ago
Activity icon

Awarded Best Reply on Laravel Decimal Number Problem.

number_format($price - ($price * $discount) / 100, 2)
Nov
17
1 month ago
Activity icon

Replied to Laravel Decimal Number Problem.

number_format($price - ($price * $discount) / 100, 2)
Activity icon

Replied to Email Verification Using Jetstream

config/fortify.php

'features' => [
    Features::registration(),
    Features::resetPasswords(),
    Features::emailVerification(),
    Features::updateProfileInformation(),
    Features::updatePasswords(),
    Features::twoFactorAuthentication(),
],

Please review the document. This will help you.

https://jetstream.laravel.com/1.x/features/authentication.html#email-verification

Nov
16
2 months ago
Activity icon

Replied to Laravel Validation

Maybe like this;

public function approve($id) 
{
	abort_if(!is_null($this->cancelled_at), 422);
	abort_if(!is_null($this->submitted_at), 422);
	abort_if(!is_null($this->approved_at), 422);
	
	$this->approved_at = now();
	$this->save();
}
Activity icon

Replied to The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD.

Use route helper:

 <form  method="POST" action="{{ route('setting_edit', $itempage->id) }}">
Activity icon

Replied to Redirect After Registration Laravel 8

These are the same thing. I recommend you look a little more carefully…

Create a RegisterResponse (same LoginResponse) class and use it.

And finally... maybe before all this you want to check out:

https://laracasts.com/discuss/channels/laravel/version-8-redirects

Nov
15
2 months ago
Activity icon

Awarded Best Reply on How To Make Multiple Validation Check

use Illuminate\Validation\Rule;

public function methodName(Request $request) 
{	
	Validator::make($request->all(), [
    		'total_distance' => Rule::requiredIf($request->status),
		// or Closure
		'total_distance' => Rule::requiredIf(function () use ($request) {
			// ..
			return true;
    		}),
	]);
}
Activity icon

Replied to How To Make Multiple Validation Check

use Illuminate\Validation\Rule;

public function methodName(Request $request) 
{	
	Validator::make($request->all(), [
    		'total_distance' => Rule::requiredIf($request->status),
		// or Closure
		'total_distance' => Rule::requiredIf(function () use ($request) {
			// ..
			return true;
    		}),
	]);
}
Nov
13
2 months ago
Activity icon

Replied to Two Laravel Project With API

Of course...

Backend: Laravel

Frontend: Vue, React, Angular, and other...

Activity icon

Replied to [Chrome, Firefox] Code Block Text Color

@gitwithravish Sorry i couldn't upload pictures properly.

Activity icon

Started a new Conversation [Chrome, Firefox] Code Block Text Color

Has anyone encountered this situation? Or does anyone know the solution?

CHROME: talltips.novate.co.uk CHROME: talltips.novate.co.uk)

FIREFOX: talltips.novate.co.uk FIREFOX: talltips.novate.co.uk

CHROME: laracasts.com CHROME: laracasts.com

FIREFOX: laracasts.com FIREFOX: laracasts.com

Note: Disabled all extensions

Oct
24
2 months ago
Activity icon

Replied to I've Been On This For Months Now And I Need Help

What exactly do you want?

For table schema you can try this;

Schema::create('messagings', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('sender_id');
    $table->unsignedBigInteger('recevier_id');
    $table->string('image')->nullable();
    $table->text('text')->nullable();
    $table->boolean('read')->default(false);
    $table->timestamps();
    
    $table->foreign('sender_id')->references("id")->on("users");
    $table->foreign('recevier_id')->references("id")->on("users");
});

You should also have a mechanism to check sended and received messages on every request.

Activity icon

Replied to Laravel Post Request

routes/api.php

Route::post("ajax-post", function() {
	dd(request()->all())
});

And make a request from your frontend app or postman, insomnia, vs code rest client extension, etc...

POST https://your-app.test/api/ajax-post HTTP/1.1
content-type: application/json

{
    "name": "Laravel API",
}
Oct
09
3 months ago
Activity icon

Replied to Mac Applications For Managing Icons?

Figma & iconify plugin

Sep
14
4 months ago
Activity icon

Replied to Version 8 Redirects

Updated Laravel Jetstream v1.2.0

I've tested and verified it works.

Thank you @snapey

Enjoy.

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

    Jetstream::deleteUsersUsing(DeleteUser::class);

    // register new LoginResponse
    $this->app->singleton(
        \Laravel\Fortify\Contracts\LoginResponse::class,
        \App\Http\Responses\LoginResponse::class
    );

    $this->app->singleton(
        \Laravel\Fortify\Contracts\TwoFactorLoginResponse::class,
        \App\Http\Responses\TwoFactorLoginResponse::class
    );
}
Activity icon

Replied to Version 8 Redirects

@snapey Yes… I follow you. Thank you for efforts. MERGED 👍

Sep
13
4 months ago
Activity icon

Replied to Version 8 Redirects

If two-factor authentication is enabled, it always goes to the "fortify.home" @snapey

Activity icon

Replied to Version 8 Redirects

@snapey

This is works, but only if disabled two-factor authentication. My app responds like this.

Is there something wrong? Is it the same for you when you use two-factor authentication?

    public function toResponse($request)
    {
        $redirect = config('fortify.home');

        // Only if two factor authentication is disabled
        $check = Auth::user()->hasAnyRole([
            "admin",
            "maintainer",
        ]);

        if ($check) {
            $redirect = route("admin.dashboard");
        }

        return redirect($redirect);

        // return $request->wantsJson()
        //     ? response()->json(['two_factor' => false])
        //     : redirect()->intended(config('fortify.home'));
    }