Rabeedmenam

Rabeedmenam

Member Since 4 Weeks Ago

Experience Points
440
Total
Experience

4,560 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
0
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
440 XP
Oct
18
1 week ago
Activity icon

Replied to Undefined Index

i did this instead tring to save record by id " 'translation_of'=> $default_category," but same hell ;D

 public function store(MainCategoryRequest $request)
    {
        $MainCategory = collect($request->category);
        $Filter = $MainCategory->filter(function ($value,$key){
                if (!isset($value['abbr'])){
                    return false;
                }
             return $value['abbr'] == Get_Default_language();
      });

        $default_category=  $Filter->first();
        $filepath="";
        if($request->has('photo')){
            $filepath = uploadImages('MainCategoryImages',$request->photo);
        }
        $default_category= main_category::insertGetId([

            'translation_lang'=> $default_category['abbr'],
            'translation_of'=> 0,
            'name'=> $default_category['name'],
            'slug'=> $default_category['name'],
            'photo'=> $filepath
        ]);redirect()->back();


        $Category = $MainCategory->filter(function ($value,$key){
            if (!isset($value['abbr'])){
                return false;
            }
            return $value['abbr'] != Get_Default_language();
        });
        if (isset($Category) && $Category->count()){

            $Category_arr=[];
            foreach ($Category as $Categories){

                $Category_arr[]=[
                    'translation_lang'=> $Categories['abbr'],
                    'translation_of'=> $default_category,
                    'name'=> $Categories['name'],
                    'slug'=> $Categories['name'],
                    'photo'=> $filepath

                ];
            }
            main_category::insert( $Category_arr);

        }

    }
Activity icon

Replied to Undefined Index

@sinnbeck thanks for your effort i appreciate it , it insert here data but not with translation inserted only one value however i entered two languages

Activity icon

Replied to Undefined Index

@sinnbeck i added index like you did now but same undefined index , the problem that Abbr not readable inside the array from $default_category however when i did dd() it gave me the data normally but in insert show that error, what am tiring to do from this function after loop the inputs according to number of language if the active language for example is English will save only the other language and if Arabic for example will save by same id the translation of that word like image i attached

Activity icon

Replied to Undefined Index

But here number one will mean the language active and Zero not active how i will update this value in DB if i removed the value

 public function scopeActive($Query){
    return $Query ->where('active',1);
Activity icon

Replied to Undefined Index

Get language function with Scope selection

function getLanguage(){

 return $select= Languages::active()->selection()->get();
}

Activity icon

Replied to Undefined Index

@sinnbeck form working fine counting inputs according to number of language and suppose no errors in form

 <form class="form" action="{{route('store.Categories')}}" method="POST" enctype="multipart/form-data">
                                            @csrf
                                            <div class="form-body">
                                                <h4 class="form-section"><i class="ft-home"></i>Add New Category </h4>
                                                @if(getLanguage()->count()>0)
                                                    @foreach(getLanguage() as $index =>$lang )
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                  <label for="projectinput1"> Category  Name -{{$lang->abbr}}</label>
                                                            <input type="text" value="" id="name" class="form-control" placeholder="Please Enter the Category Name" name="category[{{$index}}][name]">

                                                           @error("category.$index.name")
                                                           <span class="text-danger">Required  name</span>
                                                            @enderror
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="projectinput1"> Abbreviation  -{{$lang->abbr}}</label>
                                                            <input type="text" value="" id="name" class="form-control" placeholder="Please Enter the Abbreviation Name" name="category[{{$index}}][abbr]">
                                                            @error("category.$index.abbr")
                                                            <span class="text-danger">Required abbr</span>
                                                            @enderror
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group mt-1">
                                                        <input VALUE="1" type="checkbox" name="category[][active]" id="switcheryColor4" class="switchery" data-color="success" checked/>
                                                        <label for="switcheryColor4" class="card-title ml-1">Status -{{$lang->abbr}} </label>
                                                        </div>
                                                        @error("category.$index.active")
                                                        <span class="text-danger">Required </span>
                                                        @enderror
                                                    </div>
                                                </div>
                                            </div>
                                            @endforeach
                                            @endif
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <label for="projectinput1"> Image </label>
                                                        <input type="file" value="" id="name" class="form-control" placeholder="Local " name="photo">
                                                        @error('photo')
                                                        <span class="text-danger">Required </span>
                                                        @enderror
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-actions">
                                                <button type="button" class="btn btn-warning mr-1"
                                                        onclick="history.back();">
                                                    <i class="ft-x"></i> Back
                                                </button>
                                                <button type="submit" class="btn btn-primary">
                                                    <i class="la la-check-square-o"></i> Save
                                                </button>
                                            </div>
                                        </form>
Activity icon

Replied to Undefined Index

@sinnbeck after insert while am saving records

Activity icon

Replied to Undefined Index

look this the full function unfortunately same error Undefined index: abbr

the point here i want save the translation of the category in same table like the below image http://www.mediafire.com/file/70v9806m3o6uor8/error.PNG/file i have form and everything's correct in it , in the image ' Id'number 6 same 'translation_of'

 public function store(MainCategoryRequest $request)
    {
        $MainCategory = collect($request->category);
        $Filter = $MainCategory->filter(function ($value,$key){
                if (!isset($value['abbr'])){
                    return false;
                }
             return $value['abbr'] == Get_Default_language();
      });
       $default_category=  array_values($Filter->all());
       $filepath="";
       if($request->has('photo')){
           $filepath = uploadImages('MainCategoryImages',$request->photo);
       }
        $default_category= main_category::insetGetId([

           'translation_lang'=> $default_category['abbr'],
            'translation_of'=> 0,
            'name'=> $default_category['name'],
            'slug'=> $default_category['name'],
              'photo'=> $filepath
        ]);


    }
Activity icon

Replied to Undefined Index

@sinnbeck

info Dump, Die, Debug

Illuminate\Support\Collection {#277 ▼
  #items: array:2 [▼
    0 => array:2 [▼
      "name" => "Accessories"
      "abbr" => "en"
    ]
    1 => array:1 [▼
      "active" => "1"
    ]
  ]
}
Activity icon

Replied to Undefined Index

@sinnbeck has Data

array:2 [▼
  "name" => "Accessories"
  "abbr" => "en"
]
Activity icon

Started a new Conversation Undefined Index

why the below function returned Undefined index: abbr!?

*Get_Default_language(); = get local language from App

    public function store(MainCategoryRequest $request)
    {
        $MainCategory = collect($request->category);

        $Filter = $MainCategory->filter(function ($value,$key){

        return $value['abbr'] == Get_Default_language();
      });
       return  array_values($Filter->all());


    }

form

 <div class="col-md-6">
  <div class="form-group"> <label for="projectinput1"> Abbr -{{$lang->abbr}}</label>
 <input type="text" value="" id="name" class="form-control" placeholder="Please Enter the Abbr Name" name="category[{{$index}}][abbr]">

 @error("category.$index.abbr")
   <span class="text-danger">Required abbr</span>
  @enderror
    </div>
  </div>

Oct
11
2 weeks ago
Activity icon

Replied to Insert In To DB

@snapey http://www.mediafire.com/file/70v9806m3o6uor8/error.PNG/file look at this table this same wat i want to do translation of number 0 is number 6 arabic and english

Activity icon

Replied to Insert In To DB

@snapey sorry for this look but actually i changed the code alot so this why look like that , the point that i have multi language tables and i have main category table what i want to do , in insert new main category repeat the tables according to number of language i have and this okay works, the second part i tried t collect the default language by the function function Get_Default_language(){return Lang::locale();} and i called it, insertGetId() i want insert Data by ID in Table

Activity icon

Started a new Conversation Insert In To DB

what is the error with this code why not insert in to DB

    public function store(MainCategoryRequest $request)
    {
        $mainCategory = collect($request->category);
        $filter= $mainCategory->filter(function ($value,$key){
        return $value['abbr']== Get_Default_language();
        });
         $default_category=array_values($filter->all()[0]);
         $filePath="";
         if ($request ->has('photo')){
             $filePath=  uploadImages('MainCategoryImages',$request->photo);
         }
          $Default_category_id= main_category::insertGetId([

             'translation_lang'=>$default_category ['abbr'],
             'translation_of'=>0,
              'name'=>$default_category['name'],
              'slug'=> $default_category['name'],
                'photo'=>$filePath
         ]);
        $lang1= $mainCategory->filter(function ($value,$key){
            return $value['abbr']== Get_Default_language();
        });
        if (isset($lang1) && $lang1->count());
        {
            $categoired=[""];
            foreach ($lang1 as $item){
                $categoired[]=[
                    'translation_lang'=>$lang1 ['abbr'],
                    'translation_of'=>$Default_category_id,
                    'name'=>$lang1['name'],
                    'slug'=> $lang1['name'],
                    'photo'=>$filePath
                ];
            }
            main_category::insert($categoired);
        }

    }

                                        <form class="form" action="{{route('store.Categories')}}" method="POST" enctype="multipart/form-data">
                                            @csrf
                                            <div class="form-body">
                                                <h4 class="form-section"><i class="ft-home"></i>Add New Category </h4>
                                                @if(getLanguage()->count()>0)
                                                    @foreach(getLanguage() as $index=>$lang )
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                  <label for="projectinput1"> Category  Name -{{$lang->abbr}} </label><input type="text" value="" id="name" class="form-control" placeholder="Please Enter the Category Name"
                                                                   name="category[{{$index}}][name]">
                                                            @error("category.$index.name")
                                                            <span class="text-danger">Required </span>
                                                            @enderror
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label for="projectinput1"> Abbr -{{$lang->abbr}}</label>
                                                            <input type="text" value="" id="name"
                                                                   class="form-control"
                                                                   placeholder="Please Enter the Abbr Name"
                                                                   name="category[{{$index}}][abbr]">
                                                            @error("category.$index.abbr")
                                                            <span class="text-danger">Required </span>
                                                            @enderror
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group mt-1">
                                                        <input VALUE="1" type="checkbox" name="category[][active]" id="switcheryColor4"
                                                               class="switchery" data-color="success" checked/>
                                                        <label for="switcheryColor4" class="card-title ml-1">Status -{{$lang->abbr}} </label></div>
                                                        @error("category.$index.active")
                                                        <span class="text-danger">Required </span>
                                                        @enderror
                                                    </div>
                                                </div>
                                            </div>

                                            @endforeach
                                            @endif
                                            <div class="row">
                                                <div class="col-md-6">
                                                    <div class="form-group">
                                                        <label for="projectinput1"> Image </label>
                                                        <input type="file" value="" id="name"
                                                               class="form-control"
                                                               placeholder="Local "
                                                               name="photo">
                                                        @error('photo')
                                                        <span class="text-danger">Required </span>
                                                        @enderror
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-actions">
                                                <button type="button" class="btn btn-warning mr-1"
                                                        onclick="history.back();">
                                                    <i class="ft-x"></i> تراجع
                                                </button>
                                                <button type="submit" class="btn btn-primary">
                                                    <i class="la la-check-square-o"></i> حفظ
                                                </button>
                                            </div>
                                        </form>

Oct
02
3 weeks ago
Activity icon

Replied to Laravel Auth Issue With Multi Auth

@jlrdw the problem was in Route group when i removed the dashboard route from the route group that has Auth:admin it works i don't know how but it working

Activity icon

Replied to Validation Login Issue

@snapey return true

Activity icon

Replied to Validation Login Issue

the problem was in Route group when i removed the dashboard route from the route group that has Auth:admin it works i don't know how but it working

Oct
01
3 weeks ago
Activity icon

Replied to Validation Login Issue

@a4ashraf like you see i have added this but also same

=> App\Models\Admin {#3170}
>>> $admin->email = '[email protected]';
=> "[email protected]"
>>> $admin ->password = Hash::make('12345678');
=> "y$GX1N3m9qlMb0b2sAvwObV.STBSr15.tcytV3GWEorND4M4R8Xz6Tu"
>>> $admin->name = 'rabee';
=> "rabee"
>>> $admin->save();
=> true

and this in DB http://www.mediafire.com/view/npudg6a92xi6c34/Userissue.PNG/file

Activity icon

Replied to Validation Login Issue

@a4ashraf i tried both with hash and without to make sure from the spelling i guess hashing not cuz this issue

Activity icon

Replied to Validation Login Issue

@a4ashraf how i share files here , sorry am new here i am not too much familiar with laracasts

Activity icon

Replied to Validation Login Issue

@snapey i have in DB the user Name also in the form is correct gaurd working fine beacuse i i type admin in Url and any other words redirect me to admin login correctly

Activity icon

Replied to Validation Login Issue

i have in DB i added byTinker creational

Activity icon

Replied to Validation Login Issue

class Admin extends Authenticatable
{
    use Notifiable;

    protected $table ='admins';

    protected $fillable = [
        'id', 'name', 'email', 'password','created_at','update_at'.'photo'
    ];
    public $timestamps = true;

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

Activity icon

Replied to Validation Login Issue

  'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
    
        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
    ],



 'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Models\Admin::class,
        ],
Activity icon

Replied to Validation Login Issue

redirect me back to login with no errors , the point i have multi auth for admin and user admin gard in the mentioned function not work

Activity icon

Started a new Conversation Validation Login Issue

the validation function not work redirect be back to the login what is the issue here ?

  public function ValidateLogin(LoginRequest $request){

        $remember_me = $request->has('remember_me');

        if (auth()->guard('admin')->attempt(['email' => $request->input("email"),
            'password' => $request->input("password")], $remember_me))
        {
         
            return redirect() -> route('Admin.Dashboard');
        }

        return redirect()->back()->with(['error' => 'Login Filed']);
    }
Sep
30
4 weeks ago
Activity icon

Started a new Conversation Laravel Auth Issue With Multi Auth

I have Made Multi AUTH in Laravel for admin and user with Two Tables but in login there is validation error if I type any password the form logging me to Dashboard plus if i tried to access any link from Dashboard redirect me back to login ?

//controller=>
public function LoginToDashboard(Request $request){
    //validation part
    $this->validate($request,[
       'email'=>'required|email',
        'password'=>'required|min:8'
    ]);
    //need to match your user's credentials
    if(Auth::guard('admin')->attempt(['email'=>$request->email,'password'=>$request->password],$request->remember)){
        return redirect()->intended(route('admin.dashboard'));
    }
    return redirect()->back()->withInupt($request->only('email','remember'));
}
//auth.php=>.........................................
... 'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
    'admin' => [
        'driver' => 'session',
        'provider' => 'admins',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
        'hash' => false,
    ],
],
//RedirectIfAuthenticated =>.................................

public function handle($request, Closure $next, $guard = null)
{
    switch ($guard){
        case 'admin':
            if(Auth::guard($guard)->check()){
                return redirect()->route('admin.dashboard');
            }
            break;
        default:
            if (Auth::guard($guard)->check()) {
       return redirect(RouteServiceProvider::HOME);
         }
            break;
    }


    return $next($request);
   }
  }
//handler.php.................................
 protected function unauthenticated($request, AuthenticationException $exception)
{
    if ($request->expectsJson()) {
        return response()->json(['message' => $exception->getMessage()], 401);
    }

    $guard=Arr::get($exception->guards(),0);
    switch($guard){
        case'admin':
            $login='admin/login';
            break;
        default:
            $login='login';
            break;
    }
    return redirect()->guest($login);

    }