mostafasadek

mostafasadek

Member Since 1 Month Ago

Experience Points
1,850
Total
Experience

3,150 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
5
Lessons
Completed
Best Reply Awards
0
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.

Level 1
1,850 XP
Apr
01
1 day ago
Activity icon

Started a new Conversation Hi, I Want To Ask If I Can Make Video Chat But With Any Out Source APIs

I want to include video chat in laravel website but with any APIs for like hangout or Facebook messenger because i don't want to load on my server

Mar
26
1 week ago
Activity icon

Replied to "SQLSTATE[HY000]: General Error: 1364 Field 'images' Doesn't Have A Default Value (SQL: Insert Into `products` (`category_id`, `name_ar`, `name_en`, `shortDetail ▶"

Please can i send you access for me at anydesk software to see the whole code better ? or team viewer , zoom any software

Activity icon

Replied to "SQLSTATE[HY000]: General Error: 1364 Field 'images' Doesn't Have A Default Value (SQL: Insert Into `products` (`category_id`, `name_ar`, `name_en`, `shortDetail ▶"

And here is the migration

Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('category_id');
            $table->string('images')->nullable();
            $table->string('name_ar');
            $table->string('name_en');
            $table->text('shortDetails_ar');
            $table->text('shortDetails_en');
            $table->integer('quantity');
            $table->string('size');
            $table->string('color');
            $table->string('ref');
            $table->text('description_ar');
            $table->text('description_en');
            $table->text('additionalInfo_ar');
            $table->text('additionalInfo_en');
            $table->double('price', 15, 8);
            $table->timestamps();


Activity icon

Replied to "SQLSTATE[HY000]: General Error: 1364 Field 'images' Doesn't Have A Default Value (SQL: Insert Into `products` (`category_id`, `name_ar`, `name_en`, `shortDetail ▶"

Here is the product controller after editing it

 $product = Product::create([
        'category_id'=> $request->category,
        'name_ar'=> $request->name_ar,
        'name_en'=> $request->name_en,
        'shortDetails_ar'=> $request->shortDetails_ar,
        'shortDetails_en'=> $request->shortDetails_en,
        'quantity'=> $request->quantity,
        'size'=> $request->size,
        'color'=> $request->color,
        'ref'=> $request->ref,
        'description_ar'=> $request->description_ar,
        'description_en'=> $request->description_en,
        'additionalInfo_ar'=> $request->additionalInfo_ar,
        'additionalInfo_en'=> $request->additionalInfo_en,
        'price'=> $request->price,
        'images'=> $request->images,


        ]);

        $product = new Product();
        $product->category_id = $request->category_id;
// and so on for every single attribute
        $product->images = ''; // insert a empty string
// or make it nullable, or add default value



        if($request->file('images')) {
            $images = [];

            foreach ($request->file('images') as $key => $value) {
                $fileName = date('YmdHis') . "." . $products->getClientOriginalExtension();

                $images[] = $fileName;
            }

            $product->images = implode('|', $images);
        }

        $product->save();



    }



Activity icon

Replied to "SQLSTATE[HY000]: General Error: 1364 Field 'images' Doesn't Have A Default Value (SQL: Insert Into `products` (`category_id`, `name_ar`, `name_en`, `shortDetail ▶"

No but i did it below in the request because when i do it in create method it gave me error in array

Activity icon

Started a new Conversation "SQLSTATE[HY000]: General Error: 1364 Field 'images' Doesn't Have A Default Value (SQL: Insert Into `products` (`category_id`, `name_ar`, `name_en`, `shortDetail ▶"

Hi, I have this error from yesterday i tried many times to solve it but i can't so i need someone to guide me :

Product model

class Product extends Model
{
  protected $fillable =[

      'category_id','images','name_ar','name_en','shortDetails_ar','shortDetails_en',
      'quantity','size','color','ref','description_ar','description_en','additionalInfo_ar','additionalInfo_en',
      'price','created_at','updated_at',


];

Migration

public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('category_id');
            $table->string('images');
            $table->string('name_ar');
            $table->string('name_en');
            $table->text('shortDetails_ar');
            $table->text('shortDetails_en');
            $table->integer('quantity');
            $table->string('size');
            $table->string('color');
            $table->string('ref');
            $table->text('description_ar');
            $table->text('description_en');
            $table->text('additionalInfo_ar');
            $table->text('additionalInfo_en');
            $table->double('price', 15, 8);
            $table->timestamps();

        });

Controller code

 $product = Product::create([
        'category_id'=> $request->category,
        'name_ar'=> $request->name_ar,
        'name_en'=> $request->name_en,
        'shortDetails_ar'=> $request->shortDetails_ar,
        'shortDetails_en'=> $request->shortDetails_en,
        'quantity'=> $request->quantity,
        'size'=> $request->size,
        'color'=> $request->color,
        'ref'=> $request->ref,
        'description_ar'=> $request->description_ar,
        'description_en'=> $request->description_en,
        'additionalInfo_ar'=> $request->additionalInfo_ar,
        'additionalInfo_en'=> $request->additionalInfo_en,
        'price'=> $request->price,


        ]);
        $product->save();

        if($request->hasfile('images'))
        {

            foreach ($request->file('images') as $key => $value)
            {

                if ($products = $value)
                {
                    $destinationPath = 'public/files/'; // upload path
                    $fileName = date('YmdHis') . "." . $products->getClientOriginalExtension();
                    $products->move($destinationPath, $fileName);
                    $save[]['images'] = "$fileName";
                }
            }

        }

        Product::insert($save); // store file into mysql database


Mar
25
1 week ago
Activity icon

Replied to I Have Error In The Migration Table Please Urgently I Will Lost My Work

I really can't figure this out please can you help me on anydesk software

Activity icon

Replied to I Have Error In The Migration Table Please Urgently I Will Lost My Work

And please what is best way to edit the $table->unsignedBigInteger('category_id'); in the migration table

Activity icon

Replied to I Have Error In The Migration Table Please Urgently I Will Lost My Work

Thanks for your help but $categoryId isn't working with my code why

Activity icon

Started a new Conversation I Have Error In The Migration Table Please Urgently I Will Lost My Work

Please here is my migration table

 public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('category_id');
            $table->string('images');
            $table->string('name_ar');
            $table->string('name_en');
            $table->text('shortDetails_ar');
            $table->text('shortDetails_en');
            $table->integer('quantity');
            $table->string('size');
            $table->string('color');
            $table->string('ref');
            $table->text('description_ar');
            $table->text('description_en');
            $table->text('additionalInfo_ar');
            $table->text('additionalInfo_en');
            $table->double('price', 15, 8);


        });
    }

And i did this code to store multiple images

public function store(Request $request)
    {
        $input=$request->all();
        $images=array();
        if($files=$request->file('images')){
            foreach($files as $file){
                $name=$file->getClientOriginalName();
                $file->move('image',$name);
                $images[]=$name;
            }
        }
        /*Insert your data*/

        Product::insert( [
            'images'=>  implode("|",$images),
            //you can put other insertion here
        ]);


But i get this error :

"SQLSTATE[HY000]: General error: 1364 Field 'category_id' doesn't have a default value (SQL: insert into products (images) values (WhatsApp Image 2018-12-02 ▶"

Mar
24
1 week ago
Activity icon

Started a new Conversation Hi, Which Best Way To Save Product Colors In Migration Table Or The Database With Laravel Please

I want to learn how i can save colors in the database if there is link for that

Activity icon

Started a new Conversation Which Free Text Editor I Can Add It In My Website But Support RTL?

which free text editor i can add it in my website but support RTL reading and writing for Arabic language ?

Activity icon

Started a new Conversation How To Make CKEditor To Be RTL Direction.

I want to make the direction for CkEditor to be from right to left

Activity icon

Replied to How To Add Product Color In Right Way

You are helped me thank you so much.

Activity icon

Replied to How To Add Product Color In Right Way

What you mean please

Activity icon

Started a new Conversation How To Add Product Color In Right Way

Hi, I want to know how i can add product color so it be connect with points icons with colors like these circles (ooo) but every circle with it's color , I can make select option with colors names but i can make it with colorful points when i show it the products view page ?

Mar
23
1 week ago
Activity icon

Replied to Product Model

Yes but why it isn't in laravel Docs

Activity icon

Replied to Product Model

Thanks in advance.

Activity icon

Started a new Conversation Product Model

Hi, Please i want to know what is the difference between using the model like this (Category::class) :

        return $this->belongsTo(Category::class,'category_id','id');

And using it like (App\Category) , I am sorry i am absolute beginner and i saw this in project but i studied it as (App\Category) not Category::class.

Thanks for all nice people here you are very helpful and stay safe at home.

Mar
12
3 weeks ago
Activity icon

Replied to How I Can Search Inside Multiple Websites

I just need to search for word inside specific websites not all google

Activity icon

Started a new Conversation How I Can Search Inside Multiple Websites

I want to search inside(stackoverflow-devops-laravel news-laracasts) , I want to build tool with laravel that enable me to determine some websites and search inside them so if i want to search for MVC or anything , This tool will search inside only the websites that i added not in all google.

Mar
10
3 weeks ago
Activity icon

Replied to I Can't Understand The Cart Session

Anyone can explain more please.

Activity icon

Replied to I Can't Understand The Cart Session

Thank but i have problem with understanding the if session() ,, Is it condition to do what i am very sorry but i really want to understand it 100% with simple way

Activity icon

Replied to I Can't Understand The Cart Session

thanks for your reply ,But is it standard in laravel to be name with 'cart' ?

Activity icon

Started a new Conversation I Can't Understand The Cart Session

Hi, I just want to understand for whati this 'cart ' refer to in the session , i mean if i changed it to 'cartttt' or anything else is this will effect and what it will effect , I really i don't understand the sessions here

public function addToCart(Product $product) {

        if (session()->has('cart')) {
            $cart = new Cart(session()->get('cart'));
        } else {
            $cart = new Cart();
        }
        $cart->add($product);
        //dd($cart);
        session()->put('cart', $cart);
        return redirect()->route('product.index')->with('success', 'Product was added');
    }
Mar
01
1 month ago
Activity icon

Started a new Conversation Need To Practice Laravel

Hi, I am php and WordPress developer but now i learnt laravel it's great but i want to stay motivate in laravel so if anyone here can join me in real projects with him even if without salary just to keep myself with motivation not only learning , I want to practice and gain experience so please anyone give me this help.

Feb
19
1 month ago
Activity icon

Replied to Why In The Code Used Two For Loops I Mean Why It Isn't Only Loop With The Count ++ Inside It

@sinnbeck I just want ti understand when the first loop will go the the second index

Activity icon

Replied to Why Used The Reference Symbol (&) Here Because I Removed It And The Code Is Working Well .

yes but in my example they are only two outmost loops right ?

Activity icon

Replied to Why Used The Reference Symbol (&) Here Because I Removed It And The Code Is Working Well .

Yes but it will be same numbers for the variable i and j in all the array , It is ?

Activity icon

Started a new Conversation Why In The Code Used Two For Loops I Mean Why It Isn't Only Loop With The Count ++ Inside It

the code and i put my code suggestion after it in the last lines

<?php 
// PHP program to find the  
// element occurring odd 
// number of times 
  
// Function to find the element  
// occurring odd number of times 
function getOddOccurrence(&$arr, $arr_size) 
{ 
    $count = 0; 
    for ($i = 0;  
         $i < $arr_size; $i++)  
    { 
          
        for ($j = 0; 
             $j < $arr_size; $j++) 
        { 
            if ($arr[$i] == $arr[$j]) 
                $count++; 
        } 
        if ($count % 2 != 0) 
            return $arr[$i]; 
    } 
    return -1; 
} 
  
// Driver code 
$arr = array(2, 3, 5, 4, 5, 2,  
             4, 3, 5, 2, 4, 4, 2); 
$n = sizeof($arr); 
  
// Function calling 
echo(getOddOccurrence($arr, $n)); 
  
// This code is contributed 
// by Shivi_Aggarwal 
?> 
MY CODE SUGGESTION 
function getOddOccurrence(&$arr, $arr_size) 
{ 
    $count = 0; 
    for ($i = 0;  
         $i < $arr_size; $i++)  
    { 

           $count++
           if ($count % 2 != 0) 
            return $arr[$i];
}
          
    
       
    }
    return -1; 
} 
Activity icon

Replied to Why Used The Reference Symbol (&) Here Because I Removed It And The Code Is Working Well .

and why he use two (for loops) i mean what is the purpose for the loop with variable (i) and the purpose for the loop with variable ( j ) i just can't figure it out.

Activity icon

Replied to Why Used The Reference Symbol (&) Here Because I Removed It And The Code Is Working Well .

Thank you @sinnbeck but please in the same code there is return -1 what the (-1) mean in the return.

Activity icon

Started a new Conversation Why Used The Reference Symbol (&) Here Because I Removed It And The Code Is Working Well .

the reference symbol used in the function parameter

<?php 
// PHP program to find the  
// element occurring odd 
// number of times 
  
// Function to find the element  
// occurring odd number of times 
function getOddOccurrence(&$arr, $arr_size) 
{ 
    $count = 0; 
    for ($i = 0;  
         $i < $arr_size; $i++)  
    { 
          
        for ($j = 0; 
             $j < $arr_size; $j++) 
        { 
            if ($arr[$i] == $arr[$j]) 
                $count++; 
        } 
        if ($count % 2 != 0) 
            return $arr[$i]; 
    } 
    return -1; 
} 
  
// Driver code 
$arr = array(2, 3, 5, 4, 5, 2,  
             4, 3, 5, 2, 4, 4, 2); 
$n = sizeof($arr); 
  
// Function calling 
echo(getOddOccurrence($arr, $n)); 
  
// This code is contributed 
// by Shivi_Aggarwal 
?> 
Feb
18
1 month ago
Activity icon

Replied to Why The Parameter For This Function Be The Key For The Array Posts ?

Yes i understand that it is associative array but my question is why use the parameter for this function ($postttt) as a key in the array $posts or how this which step he did to use the parameter as and array key in this step . 'post'=>$posts[$postttt] @snapey

Activity icon

Replied to Why The Parameter For This Function Be The Key For The Array Posts ?

Route::get('/posts/{post}', function ($postttt) {

$posts=[
        'first-post'=>'I am number one',
        'second-post'=>'number two'
];
if(!array_key_exists($postttt, $posts)){

  abort(404,'sorrrrry');

};

return view('test',[

    'post'=>$posts[$postttt]

]);

@snapey