ehab.aboshehab

ehab.aboshehab

Member Since 2 Years Ago

Experience Points 1,160
Experience Level 1

3,840 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-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

12 Jul
1 week ago

ehab.aboshehab started a new conversation Gates Problem After Laravel's Upgrade From 5.2 To 5.8

Hi guys I am getting this Error after I finish upgrading laravel from 5.2 to 5.8 :

Declaration of App\Providers\AuthServiceProvider::registerPolicies(Illuminate\Contracts\Auth\Access\Gate $gate) should be compatible with Illuminate\Foundation\Support\Providers\AuthServiceProvide r::registerPolicies()

08 Aug
11 months ago

ehab.aboshehab started a new conversation Laravel - E-Commerce - Suggestion

Hi,

I got new project to do which is E-Commerce platform. So I will use Laravel in this project. After long time of research I have found many Open Source E-Commerce projects which built on the top of laravel. but Still i am not sure which one should I choose or use. Maybe I need some opinions from you guys if you have experienced this before.

Cheers,

01 Oct
1 year ago

ehab.aboshehab started a new conversation PLZ HELP : Localization Two Languages, Problem With Route Transaltion

Hi guys, I am really sad, there is a problem that i stuck with it for 3 weeks, I am developing a website with two languages and i am using Localization library the problem is when I am in this route for example : http://staging.yahala-int.com/en/countries/6 and trying to switch the language the id did not pass correctly to the routes translation file, so i get this url after clicking on the language switcher botton : http://staging.yahala-int.com/ar/البلدا?

The route :

Route::group(
[
    'prefix' => LaravelLocalization::setLocale(),
    'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath' ]
],
function($id)
{
    Route::get('lang/{language}', '[email protected]')->name('lang.switch');
    Route::get(LaravelLocalization::transRoute('routes.countries', ['id' =>$id]), 'website\[email protected]')->name('countries');

Language switcher function :

public function switchLang(Request $request, $lang)
    {
      $previous_url = url()->previous();
      $previous_request = app('request')->create($previous_url);
      $query = $previous_request->query();
      $route_name = app('router')->getRoutes()->match($previous_request)->getName();
      $segments = $previous_request->segments();

      if (array_key_exists($lang, config('translatable.locales'))) {
        if ($route_name && Lang::has('routes.'.$route_name, $lang)) {
          if (count($query)) {
            return redirect()->to($lang.'/'.trans('routes.'.$route_name, [], $lang).'?'.http_build_query($query));
          }
          return redirect()->to($lang.'/'.trans('routes.'.$route_name, [], $lang));
        }
        if (count($query)) {
          return redirect()->to(implode('/', $segments).'?'.http_build_query($query));
        }
        return redirect()->to(implode('/', $segments));
      }
      return redirect()->back();
    }

route translations file : en :

return [
  '/' => 'home',
  'home' => 'home',
  'countries' => 'countries/{id}',
  'areas' => 'areas/{id}',
  'hotels' => 'hotels/{id}',
  'hotel' => 'hotel/{id}',
  'room' => 'room/{id}'
];

rotue translations file : ar :

return [
  '/' => 'الرئيسية',
  'home' => 'الرئيسية',
  'countries' => 'البلدان/{id}',
  'areas' => 'المناطق/{id}',
  'hotels' => 'الفنادق/{id}',
  'hotel' => 'فندق/{id}',
  'room' => 'غرفة/{id}'
];

I do not know what I have to do, this project is on hold because this issue, any help plz :

01 Aug
1 year ago

ehab.aboshehab left a reply on Laravel Eloquent Relationship Best Practice ???

@IgorBabko for

public function getCountryIdAttribute()
    {
        return $this->area()->first()->country_id; 
    }

it gives

 (1/1) ErrorException

Trying to get property of non-object
31 Jul
1 year ago

ehab.aboshehab started a new conversation Laravel Eloquent Relationship Best Practice ???

Hi,

I have this two tables.

first one : Areas table

Schema::create('areas', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('country_id')->unsigned();
          $table->string('name')->nullable();
          $table->timestamps();
          $table->foreign('country_id')->references('id')->on('countries');
        });

Second One : Areas Translations table

Schema::create('area_translations', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('area_id')->unsigned();
          $table->string('language')->nullable();
          $table->string('name')->nullable();
          $table->text('description', 255)->nullable();
          $table->string('image')->nullable();
          $table->integer('published')->default(0);
          $table->timestamps();
          $table->foreign('area_id')->references('id')->on('areas');
        });

and these models :

first one : AreaModel

public function country()
  {
      return $this->belongsTo('App\Country');
  }

  public function translation($language = null)
  {
      if ($language == null) {
          $language = App::getLocale();
      }
      return $this->hasMany('App\AreaTranslation')->where('language', '=', $language);
  }

second one : AreaTranslationModel

public function all_translations($language)
  {
    return $this->where('published', 1)->where('language', $language)->get();
  }

  public function area()
  {
      return $this->belongsTo('App\Area');
  }

if I want to get the area's translations records where published = 1 and I want to get country_id as well from the area table.

what is the best way ???

30 Jul
1 year ago

ehab.aboshehab left a reply on Problem With Migrate (Foreign Key)

you faster than me in 36 seconds so you have the best answer @Dunsti

ehab.aboshehab left a reply on Problem With Migrate (Foreign Key)

found the problem ... the table name is areas and in the foreign key i mentioned it as area so replace : $table->foreign('area_id')->references('id')->on('area'); with $table->foreign('area_id')->references('id')->on('areas'); fixed the problem

ehab.aboshehab left a reply on Problem With Migrate (Foreign Key)

I want to mentioned something, both tables are created, but without relation.

ehab.aboshehab left a reply on Problem With Migrate (Foreign Key)

@Dunsti actually i do not have table which name is yahala. yahala is the database name.

ehab.aboshehab started a new conversation Problem With Migrate (Foreign Key)

hey guys I have problem with migration there is two tables : This is the error message :

[Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `yahala`.`#sql-4fc_
  51` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter
   table `area_translations` add constraint `area_translations_area_id_foreig
  n` foreign key (`area_id`) references `area` (`id`))



  [PDOException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `yahala`.`#sql-4fc_
  51` (errno: 150 "Foreign key constraint is incorrectly formed")

This is the First table:

Schema::create('areas', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('country_id')->unsigned();
          $table->string('name')->nullable();
          $table->timestamps();
          $table->foreign('country_id')->references('id')->on('countries');
        });

The Second table :

Schema::create('area_translations', function (Blueprint $table) {
          $table->increments('id');
          $table->integer('area_id')->unsigned();
          $table->string('language')->nullable();
          $table->string('name')->nullable();
          $table->text('description', 255)->nullable();
          $table->string('image')->nullable();
          $table->integer('published')->default(0);
          $table->timestamps();
          $table->foreign('area_id')->references('id')->on('area');
        });
21 Jul
2 years ago

ehab.aboshehab left a reply on Laravel Mix Less Variables File

any help please ?

ehab.aboshehab started a new conversation Laravel Mix Less Variables File

hey guys,

Actually I have one .less file which i was trying to make it make it .css file using MIX, but i got an error is undefined variable inside that less file. i noticed that there is another file that name is variables.less.

so how can i combine both this files together so everything should work fine ???

thanks

08 Jul
2 years ago

ehab.aboshehab left a reply on Business Logic In Model ???

@martinbean thank you so much for this clear explanation.

05 Jul
2 years ago

ehab.aboshehab started a new conversation Business Logic In Model ???

Hey guys,

I am really sorry, i do not know if i should ask such a question here... I am going to build a project for a customer as a freelance project, there is a senior web developer asked us to make sure the business logic must a functions inside the model.

actually i did not get what was he meaning by business logic inside the model ..

any help please..

02 Jul
2 years ago

ehab.aboshehab started a new conversation Rest APIs, Tokens, Angular

Hey, I am implementing a web app the back end is php laravel, the front end is an angular SPA, for this client authentication i am using passport client credentials grant, I gave the client id and the secret for the front end developer and i asked him to store it in secure place, in the first request i will generate a client token, and i will return it to that SPA, i asked the developer again to store that token in secure place as well. the problem that he told me actually any secure place in his side can be found. so what we have to ????

thank you so much

26 Jun
2 years ago

ehab.aboshehab left a reply on POSTMAN Json Body And Image Uploading

@tykus do you mean inside the request, before send it to the server ??

ehab.aboshehab started a new conversation POSTMAN Json Body And Image Uploading

hey guys, I am building a rest api that required accept a form from android app. this form has data and one uploaded image. usually in postman when i test i do like this :

Header :

Accept:application/json
Content-Type:application/json
Authorization:Bearer eyJ0eXAiOiJKV1QiLC...

Body : row JSON(application/json)

{
    "example" : "example",
    "example1" : "example1"
}

so if i want to add image to this request in postman how can i do it ??

ehab.aboshehab left a reply on Jenkins CI And Shared Host

@fideloper , i figured it out, and it working perfectly, in jenkins there is an option to use the ftp in pushing new codes to that FTP server in building process.

21 Jun
2 years ago

ehab.aboshehab started a new conversation Jenkins CI And Shared Host

is it possible to build to shared host using jenkins ???

09 Jun
2 years ago

ehab.aboshehab started a new conversation HTTP FAILED: Java.net.SocketTimeoutException: Connect Timed Out

hey guys, I am working on project and i am using laravel 5.4, and restfull API, I am facing a problem. that we when i update anything in the database the the android client get this error : HTTP FAILED: java.net.SocketTimeoutException: connect timed out any idea ???

05 Jun
2 years ago

ehab.aboshehab left a reply on Pass Data To Modal Dialog

@goatshark actually it's in the same file. but the problem is the data is really big, and if i have more that 1000 records in the table i will not get all the details for all records with just opening the table .. i need to get the data per record... btw i am using jquery

ehab.aboshehab started a new conversation Pass Data To Modal Dialog

Hey,

If i have a table with five columns (name,email,phone, dob and action) the action column has a details button, when i click this button there is a modal dialog will open and it should display more information about the requested row. so i do not know how to pass these extra details to this modal dialog. any help please ...

thanks

04 Jun
2 years ago

ehab.aboshehab left a reply on Laravel Eloquent Get 10 Records From Id = 10

@tekmi thank you so much i used your solution. @EventFellows thank you so much for your answer, actually i used his answer because my case is i want to send 10 records for each request. for example i sent from 1 to 10 then the app side will pass me the id of the last record that i sent so i will send from 11 to 20 in the next request and ....etc

ehab.aboshehab started a new conversation Laravel Eloquent Get 10 Records From Id = 10

hey guys,

I want to get 10 records from table but i want fetching the data from specific id

$news = News::where('category_id',$categoryID)->limit(10)->get();

thank you so much for helping

30 May
2 years ago

ehab.aboshehab left a reply on RestFull API

fixed

ehab.aboshehab started a new conversation RestFull API

Hey guys, I am using restfull api, everything is working fine when i am trying to test using POSTMAN, but when i tried to test from android side i got this error with the response :

com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonObject

28 May
2 years ago
27 May
2 years ago

ehab.aboshehab started a new conversation [Illuminate\Database\QueryException] SQLSTATE[HY000]: General Error: 1005 Can't Create Table

Hi, i am trying to put a foreign key ...

            $table->increments('id');
            $table->string('news_category')->nullable();
            $table->timestamps();
        });

```Schema::create('news', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned();
            $table->string('title')->nullable();
            $table->longText('description')->nullable();
            $table->string('image')->nullable();
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('news_categories')->onDelete('cascade');
        }); 

ehab.aboshehab left a reply on Model And Controller For Categories ?

@Snapey can you help me please ..

ehab.aboshehab left a reply on Missing Argument 1 For Illuminate\Database\Eloquent\Model::destroy()

Try this, it should work ..

public function destroy($id) { $post = Post::find($id);

  $post->delete();

  return redirect('posts');
}

ehab.aboshehab started a new conversation Model And Controller For Categories ?

Hey guys, If I have news that I should display it in my app but these news have many categories ? so I think i will make two tables news_table and categories_table with oneToMany relationship ... is this the best practice ??? if it is should I do two models one for each ?? or just one model for the news table ??

thanks

25 May
2 years ago

ehab.aboshehab left a reply on Php Artisan Serve

@Benja @MalaniDerrick thank you guys for the reply, but I did these things before posting my question here. but the problem is when i try to type php artisan serve (with any port) the server stopped after the first http request ..

ehab.aboshehab started a new conversation Php Artisan Serve

hey guys,

some thing weird is happening with my laravel project, and actually i do not know if it laravel issue or not. the problem is after doing (php artisan serve) command the server is disconnected after the first http request. and it doesn't give any error. can you help please .

22 May
2 years ago

ehab.aboshehab started a new conversation Laravel/Passport

hey guys, Actually i am trying to build an API using passport for authentication, everything is going well. but I should make a social network authentication (facebook,google), i thought i can do it with Socialite. but the guy who is doing the android side suggest to done the social login from his side using firebase and he will pass me the required data that will come from the social media itself (name,email,id,token .... ) ... so i generated a password for each user who registered via social networks so i can generate an access token. but i got problem with generating the access token, it gives me the credentials is incorrect, with the knowing that I am sure from each single information that I am using for generating the access token (username,password,client_id,client_secret and the grant_type). Note: when the user make normal registration I can generate the token successfully.

Thank you,

17 May
2 years ago

ehab.aboshehab left a reply on Laravel/Passport And Social Network Authentication

@shakti i thought in this before, but i do not know if it's the best practice or not ...

ehab.aboshehab started a new conversation Laravel/Passport And Social Network Authentication

hey guys, Actually i am trying to build an API using passport for authentication, everything is going well. but I should make a social network authentication (facebook,google), i thought i can do it with Socialite. but the guy who is doing the android side suggest to done the social login from his side using firebase and he will pass me the required data that will come from the social media itself (name,email,id,token .... ) ... now the question is after i get these data i stored in the database and I am trying to generate an access_token and refresh_token for this user, but because there is no password for this user and because he is done his login using the social media, I am not able to generate the token, and it gives me an error the user credentials were incorrect ... actually i do not know if I am using this in the right way or not ... i really need help ... the internet is really poor about this issue i could not find some thing helpful.

Thank you,

11 May
2 years ago

ehab.aboshehab started a new conversation Return Value From Function Inside Controller To Another Function Inside Another Controller

Hey, Actually I have two controllers and each controller has a function, I am calling the second function from the first function, but the problem is I am returning the value from the second function using return, as you know the code will not execute after the return, so what should I do ? class FirstController extends Controller { public function first_function() { echo $data = (new SecondController())->second_function(); } }

class SecondController extends Controller { public function second_function() { $data = "anything"; return $data; } }