yumna12-coder's avatar

yumna12-coder wrote a reply+100 XP

2mos ago

I apologize for not doing my research first.

yumna12-coder's avatar

yumna12-coder wrote a reply+100 XP

2mos ago

Is there a course you would recommend for database design? I am having trouble understanding some concepts

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

2mos ago

Why Isn’t MySQL Database Design Included in the Laravel Path?

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

2mos ago

Why can't I watch the lessons? There's only a black screen for all the courses.

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

2mos ago

Route::get('/{Locale?}',function($Locale=null){ if(isset($Locale)&& in_array($Locale,config('app.available_Locales'))){ app()->setLocale($Locale);

}

return view('welcome');

});

how to add this for all my route without using middleware

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

2mos ago

Is there a Laracasts video/tutorial that demonstrates using Spatie Laravel Translatable for Eloquent models? If yes, which series or episode?

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

3mos ago

protected $casts = [ 'Is_trend' => 'boolean', ];

{{ $product->Is_trend }}

Why does this print 0 instead of false?

I thought that casting means converting the attribute’s type into another type. So if Is_trend is cast to boolean, why is 0 printed in the Blade view?

Also, I’m trying to understand the real benefit of using $casts. What problem does casting actually solve in Laravel

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

First don't be too hard on yourself. Everything you stated as challenging are very large areas of programming in general. Everyone finds them challenging. The good news is their are various courses on Laracasts that can help you.

I had difficulty with Testing and I'm still not great a it. I found watch this course help me a lot.

https://laracasts.com/series/php-testing-jargon

Also I recommend reading the Laravel documentation. I know it sound scary but the documentation is very human friendly to read and understand.

If you just struggling with the PHP in general I would recommend "PHP For Beginners" and the "PHP Crash Course" on Laracasts.

Authorisation is a massive topic and even after all my 20+ years as a developer I'm still learning on this subject. The best way to pick it up is to create a simple app yourself.

Start with a Laravel start kit. Use something like Laravel Breeze starter kit and learn to use the existing Auth process. By doing this you will learn the basics and you can look at the start kit codebase and start reading it to understand what going on.

Here a very good Laracasts course on the subject

https://laracasts.com/series/laravel-authentication-options

If you still don't understand I suggest copying the script into chatGPT and asking it to explain in detail what each line does and why, it can be a helpful exercise if you don't understand something.

Gate and Policies sound more complex than they really are. They are just layers you can add to system security. You don't have to master everything all at once. Just learn to get comfortable with Authorisation then once your good start playing with Gate...then Policies. Before long you will start feeling comfortable with everything.

Just remember programming is creative exercise and you learn through play. So just have fun and play.

As far as Vite and UI I would recommend watching.

https://laracasts.com/series/laravel-and-vite

I hope the above helps you and if you have any particular questions just let me know and I've tried and explain it to you.

All the best :-)

yumna12-coder's avatar

yumna12-coder wrote a reply+100 XP

3mos ago

Thank you very kindly.

yumna12-coder's avatar

yumna12-coder wrote a reply+100 XP

3mos ago

I understood the fundamentals well up to Request Validation, and I also understood relationships and the authentication video. However, I found testing, authorization using Gates and Policies, Vite,Digging Deeper videos , and working with the UI challenging.

When I watch the videos, I usually follow along and implement the code with the instructor, but I don’t always stop to think of alternative approaches. Maybe this affects how deeply I understand the concepts.

I also tried learning from multiple resources, and I think that made me a bit confused about what to rely on. Right now, I’m looking for a clear learning path that I can commit to and follow consistently

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

@yumna12-coder You might not be ready for this series. Can you describe precisely what you found difficult, and we can point you to a place to learn more?

yumna12-coder's avatar

yumna12-coder wrote a reply+100 XP

3mos ago

I understood the fundamentals well up to Request Validation, and I also understood relationships and the authentication video. However, I found testing, authorization using Gates and Policies ,Vite, Digging Deeper videos and working with the UI challenging.

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

Can you mention what you didn't understand? It seems he is just implementing some optional tools in the one video and second video just setting up basic laravel items for the crud of the application.

In the first video you can go to the various tool sites and read more about them.

On the second video, you can pause and view the laravel documention for a better understanding of the current task being covered.

Also consider the PHP courses here on laracasts, they will help. Also a view of the 30 days to learn laravel might help.

You are better off actually not just viewing this stuff, but code (not copy and paste) as you are learning. Meaning actually typing it out on the keyboard. But if he copies a section of code elsewhere, then it's okay to copy and paste like he did in the video.

In each segment, learn the "why" of what he did.

And if it takes longer to understand something, that's okay too, we were all new to programming at one time.

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

3mos ago

how to validate image ? public function addproduct(AddProductRequest $request){

$imagepath=null; if($request->hasfile('image')){ $imagepath=$request->file('image')->store('photos','public');}

 $product = Product::create([
    'name'=> $request->validated('name'),
    'price'=> $request->validated('price'),
   'description'=>$request->validated('description'),
   'Is_trend'=>$request->validated('Is_trend'),
   'image'=>$imagepath,


 ]);

return redirect()->back()->with('success', 'Product added successfully!');

}

public function rules(): array
{
    return [


     'name'=>'required|string',
     'price' => 'required|numeric|min:0|max:999999.99',
     'description'=>'string',
     'Is_trend'=>'boolean',
     'category_name'=>'exists:categories,name',
     'image'=>'nullable|image|mimes:jpg,png,gif|'
        //
    ];
}
yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

3mos ago

If I found laravel-from-scratch-2026 course difficult, is there a simpler level than this? And what is the best way to study the course?

For example, the first two videos of the final project took me two days and I still didn't fully understand them.

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

3mos ago

Why gives me error when using make method?

$idea=App\Models\Idea::factory()->make();

Error Call to undefined method ArrayObject::set().

$idea=App\Models\Idea::factory()->raw(); = [ "user_id" => 19, "name" => "Dicta assumenda iusto sed debitis porro nesciunt et.", "description" => "Ut commodi facilis autem dolores molestiae facilis veritatis. Eligendi facilis quo in enim. Voluptate non eos dolores blanditiis pariatur. Saepe nihil illum consequatur consequuntur voluptatem modi vitae.", "links" => [ "http://wiegand.com/necessitatibus-ut-omnis-iste-a-odit-dolorem-dolorem", ], ]

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

You use the query builder to build database queries through method calls. You don't usually need to write any SQL code yourself, but if you need something specific, you can use the DB::raw() method to inject raw SQL in the query.

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

Use it for advanced cases when it is simpler to use raw SQL rather than master complex Eloquent expressions with nested closures etc.

yumna12-coder's avatar

yumna12-coder liked a comment+100 XP

3mos ago

Certainly! Let's break down your questions:

1. What is a "row expression" in Laravel / Eloquent context?

A row expression typically refers to a part of a SQL query that computes or returns values per row, often with functions or calculations. In Laravel, you use DB::raw() to write such expressions when Eloquent's query builder doesn't provide what you need with its built-in methods.

2. What is DB::raw?

DB::raw lets you write raw SQL inside your queries. For example:

->select(DB::raw('count(*) as user_count, status'))

Here, you are telling Laravel to select two columns:

  • count(*) as user_count: Counts the number of rows for each group (if used with groupBy).
  • status: The status column.

It's useful when you need SQL features not available directly in Eloquent.

3. When should you use DB::raw and row expressions?

  • When you need aggregate functions (COUNT, SUM, MAX, etc.)
  • When you want to call SQL functions, or use calculated columns.
  • When Eloquent's query builder doesn't offer a built-in way to do what you want.

4. Example:

Suppose you want to count the number of users per status:

$users = DB::table('users')
    ->select(DB::raw('count(*) as user_count, status'))
    ->groupBy('status')
    ->get();

This returns data like:

[
    { "user_count": 5, "status": "active" },
    { "user_count": 2, "status": "inactive" }
]

In summary:

  • Use DB::raw (and thus "row expressions") when you need custom select columns or calculations in SQL not directly supported by Laravel's query builder.
  • Always be careful with user input to avoid SQL injection, and prefer built-in methods when possible for safety and readability.

Let me know if you want more concrete examples!

yumna12-coder's avatar

yumna12-coder started a new conversation+100 XP

3mos ago

When should I use this DB::ROW? TO BE HONEST I do know what is raw expression means

->select(DB::raw('count(*) as user_count, status'))