fenos

fenos

Member Since 5 Years Ago

Experience Points 19,325
Experience Level 4

675 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 415
Lessons
Completed
Best Reply Awards 14
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

18 Oct
3 years ago

fenos started a new conversation Codeception And Laravel Failing With Exists Rule

Hi guys, i'm having a failing test, when the exists rule is set on an entry point (validation) with Codeception and Laravel.

I'm using the Laravel5, Rest Module of Codeception. I'm using the cleanup option to true so that it run each tests in a DB transaction.

The problem it's that the field it's not somehow recognised from the Laravel validator even do I create it before initiate the Request here a little example:

public function rules()
{
    return ['user_id' => 'required|exists:users,id'];
}
public function store(ApiTester $I)
{
    // Create a couple of users
    $users = factory(\App\Models\User::class, 2)->create();

    $I->authenticateAs($users[0]);
    $I->sendPOST('users/' . $users[0]->id . '/friendships', [
        'user_id' => $users[1]->id
    ]);
    $I->seeResponseCodeIs(201);
}

This will fail with a validation error saying that the user doesn't exists in the DB. A guy posted a question on stack overflow (where I steal his examples but they reflect my same issue). http://stackoverflow.com/questions/33085786/testing-a-laravel-5-route-with-an-exists-rule-via-codeception

Maybe you guys have some experience with it. thanks

02 Sep
3 years ago

fenos left a reply on Management Of Seeders

@hstung11 Thanks i will check it out

@mstnorris I understand your system but let's say that you add just one more record to your Constants seeder how do you add it into your production website? you can't re-seed your ConstantsTableSeeder i'm right?

01 Sep
3 years ago

fenos started a new conversation Management Of Seeders

Hi guys, while building my app, I created few seeders of data that the app needs to run. This data will needed for the app to categorise other data.

When going in production there will be a occasion where i would need to add new data into my app, for example a new brand of cars.

Thinking in a production environment i wouldn't like to update my database manually, but i rather think to a kind of migrator of seeds, (in the same way the migrations works) keeping track of the seeded data.

What are your experience on adding data to your database in a production environment?

Which technique you use to add them efficiently?

Thanks for any advise

29 Jul
3 years ago

fenos left a reply on Change S3 Credential At Runtime With Laravel 5.1 / Filesystem

for anyone who had a similar issue, as following how i solved (Laravel already give this feauture) :

$this->fileSystemManager->createS3Driver([
            'key' => $permissionsAccess['key'],
            'secret' => $permissionsAccess['secret'],
            'bucket' => $permissionsAccess['bucket'],
            'region' => $this->config->get('filesystems.disks.s3.region')
]);

fenos started a new conversation Change S3 Credential At Runtime With Laravel 5.1 / Filesystem

Hi guys, in my app I have the needs to change aws3 default setting, in specific actions.

For example my default public settings are pointing to a user of AWS3 called appUsers how you know in AWS under the IAM feature we can have different users with different credentials and permission.

At this point when the an admin of the app it's uploading a file in a specific form i need to grant access with another account of AWS, so i need to change the Access Key - Secret Key - Bucket name for that specific action.

Laravel 5 set up Filesystem credentials on the ServiceProvider, so i was thinking to change the configuration options as following (before the actual upload):

$this->config->set('filesystems.s3.key',$permissionsAccess['key']);
$this->config->set('filesystems.s3.secret',$permissionsAccess['secret']);
$this->config->set('filesystems.s3.bucket',$permissionsAccess['bucket']);

But obviously it doesn't reflect the changes on the FileSystem class which it's already instantiated with the default configuration.

Any help will be appreciated. Thanks

26 Jul
3 years ago
26 Jun
3 years ago

fenos left a reply on Working Payment System??

@bzndk I'm sorry for you, but if you want learn Laravel on the right way, you can't go anywhere :). You should have just patience, every thing will be sort out, if you want to be a customer Jeffrey will help you 100%, Peace!

17 Jun
4 years ago

fenos left a reply on How To Fetch Available Relations In Eloquent

@phildawson That's worked just amazingly!! I tweak it a little for my needs, but very very helpful, thanks!!

fenos left a reply on How To Fetch Available Relations In Eloquent

@phildawson Thanks very much, i'll try to implement and i'll let you know, very thanks for you time :)

fenos left a reply on How To Fetch Available Relations In Eloquent

@phildawson Thanks for the suggest it might make sense for parent relations, let's say that App\Foo is the parent model then i'm going to ask for cars.trader so 2 deep relations. There is anyway to check if they really exists?

@JhonRivs i read the answer and I think we have to query first to get the relationships, of the given model, I'm trying to check before query the model.

fenos started a new conversation Ho To Fetch Available Relations In Eloquent

Hi guys, i'm writing a script and I need to check which relations are available on the Eloquent model before run a query.

I'm receiving a input from the front end called include (if you used fractal will be familiar to you) , this include will be the requested relations that we want to append to the final input. I want to eager load them safely checking that the relations does exists.

Example:

Requested include

0 => [
    'include' => 'cars.trader'
]

I would like to check in eloquent if is possible to apply this eager loading relations.

For first level relation i might check if the method exists on the model, but how can i check for nested one?

Any help will be appreciated

01 Mar
4 years ago

fenos left a reply on Routes Https On Loader Balance

Thanks so much @fideloper, you save me a lots time and stress :))) it works amazing!! My only concern is, I'm using amazon load balancer, I installed your package and set up as a trusted proxy the DNS entry point of the balancer as the following:

 'proxies' => [
        'mybalancerentrypoint.elb.amazonaws.com',
    ],

I done in this way for the suggestion of amazon it self on this note:

Note: Because the set of IP addresses associated with a LoadBalancer can change over time, you should never create an "A" record with any specific IP address. If you want to use a friendly DNS name for your load balancer instead of the name generated by the Elastic Load Balancing service, you should create a CNAME record for the LoadBalancer DNS name, or use Amazon Route 53 to create a hosted zone.

is it a correct way to set up the proxy and it's secure enough?

also dumping the $_SERVER global variable i seen the headers sent from the balancer as the same of your default headers in the config file :))

fenos started a new conversation Routes Https On Loader Balance

Hi guys, I have a Load balancer running on HTTPS and behind we are running the communication in normal HTTP (between the balancer and the APP servers).

Using the https option on a router group as the following:

$router->group(['https'], function ($router)
{
require app_path('Http/routes.php');
});

it apply correctly the prefix https to all the url. When i try to navigate on the site, on every url I receive a 404 status code and I'm not able to see the pages using this filter.

Do you have any suggestion guys or why it behave like so?

fenos left a reply on [L5] Environment Variables On Server

@bashy thanks to point me in that link, i think is that the problem, i'll try it as soon as possible, cheers :)

fenos left a reply on [L5] Environment Variables On Server

I'm not sure why does not work with fastcgi parameters my nginx version is 1.6.2. By the way yes bashy :p

fenos left a reply on [L5] Environment Variables On Server

oh ok, should i have one file .env on the production then? using forge i don't need it :p

fenos started a new conversation [L5] Environment Variables On Server

Hi guys, i'm deploying an application for a friend of mine in amazon ec2 without using Laravel forge.

I can display correctly the home page of my application, but somehow the application Doesn't read the env() variables.

I set them up on /etc/nginx/site-availables/default as the following:

location ~ \.php$ {
                fastcgi_param DB_PASSWORD "password";
                fastcgi_param DB_USERNAME "myusername";
                fastcgi_param DB_NAME "mydbname";
                fastcgi_param DB_HOST "myhost";
                fastcgi_param ENV "production";
                fastcgi_param DEBUG "true";
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                include fastcgi_params;
                fastcgi_index index.php;
        }

But none of them are read from the application. Where i'm doing wrong? :(

22 Feb
4 years ago

fenos started a new conversation DB Schema For Sports Statistics

Hi guys, I'm working in a project where I have to keep track of the statistics of some athlete.

I have a athlete table with some info about him, but every sport has different types of statistics, Ex: in boxing I want to know the weight, but in tennis i don't need the weight, but Eg. if is left handed or right handed.

I need a suggest to how to define the statistics tables in a way that I can store those statistics accordantly to the sport even if they are different between every sport.

What do you suggest? :) Thanks!

20 Feb
4 years ago

fenos left a reply on L5: How To Redirect

@blackbird absolutely is not a competition, i think, I just given a bit more detailed answer for be marked as correct as reference to others readers. That's all nothing against :)

fenos left a reply on L5: How To Redirect

@MyOkram I don't understand why is not my answer to be the correct one. Didn't it help you?

fenos left a reply on L5: How To Redirect

@MyOkram No problem, this small thing fit perfectly to be middleware because it will be triggered before the request is passed to the action. If you think even check if the user is logged in is not a big deal just an if statement, but you want to check that before the request trigger your controller :)

fenos left a reply on Primary Key Id Organizing

Don't worry about the number or order of your ids, the idea of ID is to have a unique identifier for your records.

fenos left a reply on L5: How To Redirect

This is the perfect case for a middleware.

Because laravel 5 has got 2 types of middleware, 1 for routes and 1 for the global boot of the application. You can register your own global middleware in the App\Http\Kernel.php under the $middleware property.

it may look like this:

AllowedHostMiddleware.php

class AllowedHostMiddleware implements Middleware {

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(!in_array($host, $allowedHosts)) {
                           return redirect($defaulthost);
                }

                return $next($request);
    }

Kernel.php

    protected $middleware = [
        'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
        'Illuminate\Cookie\Middleware\EncryptCookies',
        'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
        'Illuminate\Session\Middleware\StartSession',
        'Illuminate\View\Middleware\ShareErrorsFromSession',
                'App\Http\Middleware\AllowedHostMiddleware'
    ];
19 Feb
4 years ago

fenos left a reply on [L5] One Time Payment Casher

@Ruffles @Mike Hopley Thank you very much it make sense :)

fenos left a reply on [L5] One Time Payment Casher

@blackbird I don't want do a subscription plan, one time payment like when you buy a product in a e-commerce does it make sense to you? :) ( obviously i appreciated your time to try to help)

fenos left a reply on [L5] One Time Payment Casher

@Ruffles Thanks i forgot about that series i just watched and it's really helpful, but it doesn't use Laravel Cashier but the original stripe API. I was hoping was possible to do it with Cashier.

@blackbird Mmmh it can be an "hack" way to do that, I prefer to don't assign the user to any subscription if they pay once. :)

fenos started a new conversation [L5] One Time Payment Casher

Hi guys, I want to implement one way payment with Stripe and Laravel Cashier. Reading the documentation I didn't find any methods that allow to do this.

How did you manage to implement this future?

Thanks guys for any suggest :)

15 Feb
4 years ago

fenos started a new conversation [migrations] SQLite General Error: 1 Cannot Add A NOT NULL Column With Default Value NULL

Hi guys, I'm having problems with my migrations and sqlite, let me explain :)

I created a migration that add a column to an existing table. it looks like this:

    public function up()
    {
        Schema::table('organisations', function (Blueprint $table){
                      $table->string('long_name');
                });
    }

    public function down()
    {
        Schema::table('organisations', function (Blueprint $table){
                         $table->dropColumn('long_name');
                });

Running this as a migration in MySQL for actually insert the new column, it worked just fine.

When running the same migration on SQlite (For testing purpose), it throw the following error:

PDOException: SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

I first googled a bit about this issue and came a cross to this Blog post

https://www.alfrednutile.info/posts/64

It say that when you are getting this issue, apply the new field as nullable. I personally, don't want the field to be nullable. :(

There is some workaround for it?

Thanks guys if you have any ideas about this :)

12 Feb
4 years ago

fenos started a new conversation Behat 3 Check Radio Buttons

Hi guys, I have a registration form where you can select a gender through a Input Radio. How can i check one of the values with behat?

I tried to google it a bit but I didn't find any good resource. Any of you have experienced this problem too?

public function iRegister($email, $password)
    {
        $this->visit('/');

        $this->fillField('name','Jhon');
        $this->fillField('surname','Smith');
        $this->fillField('username','fenos');
        $this->fillField('email',$email);
        $this->fillField('password',$password);
        $this->fillField('repeat_password',$password);
        
        // I should check the radio input here

        $this->pressButton('Register');
    }

Thanks

11 Feb
4 years ago

fenos left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting!

Which emakl driver are you using?

fenos left a reply on OrderBy Using Foreign Column And Eloquent

@JarekTkaczyk well you are right, I thought he want to order by the eager loading qjery, in this case your answer is correct :)

10 Feb
4 years ago

fenos left a reply on OrderBy Using Foreign Column And Eloquent

If i have understood correctly you can order an eager loading query as the following:

SocialTax:with(['year' => function($year) {
     $year->orderBy('created_at','desc');
}])->get();

fenos left a reply on Maximum Function Nesting Level Of '100' Reached, Aborting!

I had this issue too! Just make sure that you have your config\mail.php filled corrected with the right driver and credentials. Double check that your form key has the address and name set. I solved in this way. :)

'from' => ['address' => 'your@email.com', 'name' => 'Your Name'],

fenos left a reply on I'm New, Would This Work Out In Laravel?

@KieronWiltshire first buy a subscription here in laracasts, it's really cheap and will be the best investment you done for your future project. The second investment you'll have to do is the time to watch and learn the good resources on the website.

If you want a quick review on how OOP works in PHP here is your starting point! :)

https://laracasts.com/series/object-oriented-bootcamp-in-php

I suggest to watch videos and create a new projects where you actually try what Jeffrey show :)

Ps: with laravel you can do everything!

Good luck!

fenos left a reply on [L5] Understanding Package Development

@max23 Hi max, i solved the problem as for laravel 4, I used Orchestra\TestBench package. It has all the boilerplate to bootstrap the framework and run our integration tests during the package development.

Repo : https://github.com/orchestral/testbench

fenos left a reply on [L5] Sync Queues

Yes that correct, you will use "sync" driver for development purpose it will just mimic a queue, then when going to production you'll swap to your required driver and if your setup is correct all will work as expected.

09 Feb
4 years ago

fenos left a reply on [L5] Understanding Package Development

@max23 yes exactly, it can't be the solution for it because then you can't delivery the tests into your package as I want too :) Sure we will find some solution. :) I'm still trying to make it work :p

fenos left a reply on Form Inside A Form

well, you can't have nested forms. Instead in you controller you can require the field names that you need and store them in whatever table you want, example:

** ExampleController.php**

function storeForm() {

     $inputsTableA = Request::only('name','surname');
     $inputsTableB = Request::only('description','email');

      User::create($inputsTableA);
      UserProfile::create($inputsTableB);
}

Hope it helps :)

fenos left a reply on Laravel 5 And Behat - Form Testing

@remoblaser I don't see nothing wrong with the form, but instead it seem that your are trying to store the _token field into the database. Can you please share how do you pass the inputs to the model for create a new record? Also check your self if you are getting that input involved during the creation of that record.

fenos started a new conversation Bootstrap Laravel 5 In Package Development

Hi guys, I got stuck during the upgrade to L5 of 1 package. This package run integration tests to a Database (sqlite in memory). With laravel 4 I had successfully bootstrapped the framework and run the tests without problems.

Because now Laravel5 use Kernels i don't understand how to bootstrap it only for development purpose.

I had a previous question about this without have a point to start trying:

https://laracasts.com/discuss/channels/general-discussion/l5-understanding-package-development?page=1#reply-30184

I hope someone can help me out with this :)

07 Feb
4 years ago

fenos left a reply on [L5] Understanding Package Development

@JanHenkG Yes, I pulled in "laravel/framework": "5.0.*" as dependency, but I don't understand how to bootstrap the framework for run the tests. Because i'm developing a package I don't have the kernels of console and http.

@JarekTkaczyk This the following example test:

Notification Repository

use Laracasts\TestDummy\Factory;

class NotificationCategoryRepositoryTest extends TestCaseDB {

    /**
     * @var CategoryRepository
     */
    protected $categoryRepo;

    public function setUp()
    {
        $this->categoryRepo = new CategoryRepository( new NotificationCategory());

        parent::setUp();
    }
    
    /** @test */
    function it_find_a_category_by_id()
    {
        $record = Factory::create('Fenos\Notifynder\Models\NotificationCategory');

        $category = $this->categoryRepo->find($record->id);

        $this->assertEquals(1,$category->id);
    }

TestCaseDb Is the class where I should bootstrap and set up the framework, here is where I'm stuck, because the bootstrap is not bootstrapped correctly I got Exception :

Class 'Artisan' not found in /Users/me/LaravelProjects/Projects/pack/Notifynder/tests/TestCaseDB.php on line 12
abstract class TestCaseDB extends Illuminate\Foundation\Testing\TestCase {

    public function setUp()
    {
        parent::setUp();

        // This should only do work for Sqlite DBs in memory.
        app('artisan')->call('migrate');

        // We'll run all tests through a transaction,
        // and then rollback afterward.
        app('db')->beginTransaction();
    }

    /**
     * Rollback transactions after each test.
     */
    public function tearDown()
    {
        parent::tearDown();
        app('db')->rollback();
    }

    // Here where I should create the application
    // the following is just some trial (not working)
    public function createApplication()
    {
        $app =  new \Illuminate\Foundation\Application(
            realpath(__DIR__.'/../')
        );

//        $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();

        return $app;
    }
}

fenos left a reply on [L5] Understanding Package Development

none can help? I'm struggling to bootstrap the framework to run my DB tests any of you had experience in this?

03 Feb
4 years ago

fenos left a reply on Live On NoCapes

@JeffreyWay I really enjoyed watching the cast, will you do this again? :))))

fenos left a reply on [L5] Understanding Package Development

@AtoZ No problem, My issue is not unit testing a Model, but to do Integration test of my Repositories directly from my package. If you take a look the repository "illuminate/support": "~5.0" it doesn't provide you full framework classes, but just useful contracts and Helpers.

Thanks anyway :)

fenos left a reply on [L5] Understanding Package Development

@AtoZ Yes I know that Eloquent is an Alias I think you didn't get my question. :p

fenos left a reply on Live On NoCapes

Just watching you!! :))))

fenos started a new conversation [L5] Understanding Package Development

Hi guys, I want to update my Laravel 4 packages to Laravel 5 for all you guys. I would like deliver the updated package with unit and integration tests running on Trevis CI I just need some of your precious suggests.

My understanding

Laravel 5 has removed the workbench feature (no problem), so for create a new package just create a new folder and init composer installing the dependencies.

Dependencies composer.json

As I know when developing packages we have to pull in the "illuminate/support": "~5.0". Taking a look his components they are useful Contracts and Helpers.

Question My current package use Eloquent in it's features, illuminate/support doesn't provider it. Should i pull in the "laravel/framework": "5.0.*" component to be able to use it?

** Testing **

How I said my package use Eloquent so it means run queries for you, I want to be able to set up my integration tests with sqlite in memory.

My previous experience in L4 this process was a bit tricky even if pulling the Orchestra\TestCase package was helping us to set environment to testing and other useful stuff.

Question

I feel forced to pull in the "laravel/framework": "5.0.*" in this case, otherwise how can I bootstrap the application for run my integration tests in memory? am I right?

If you have experience with the "new system" of packages development please do light on this questions. Thank you!

02 Feb
4 years ago

fenos left a reply on Multiple Fields In Relation With A Table

@pmall wow, I don't know why I didn't think about manyToMany relation, I'm getting old!! :( You are definitely right! :) Thanks a lot!!

fenos left a reply on Multiple Fields In Relation With A Table

@JarekTkaczyk Thanks, you are right but is not that easy to explain it :p I'll try to do my best

In few words I would like achieve a clean way to have a big list of injuries and it's type stored in my DB, and relate their ID to a user in a hypothetical injury_table.

Let's say that my boss will ask me: Can you please give me a list of the body region injured? Yes I can

$id = select id from injuries where type="region" and name="body" limit 1
select * from user_injury where injury_region_id=$id