malhayek

Experience

23,780

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 165 Lessons Completed
  • 22 Favorites

25th March, 2017

malhayek left a reply on How Can I Submit Code Improvement Of Laravel To Taylor? • 1 day ago

@clay So I forked the laravel/framework project. I made the changes and a commited/pushed my changed. My new code is now on my forked project on git hub.

Now, I want to submit my change for Taylor hoping he'll merge my code with the master branch.

I went to the original project (https://github.com/laravel/framework) and clicked on "New Pull Request" which sent me to this link https://github.com/laravel/framework/compare?expand=1

I am confused on which branch/tag to I pick and also how to I tell it to take my code and send it?

21st March, 2017

malhayek started a new conversation How Can I Call A Listener Outside The Score Of A Database Transaction? • 5 days ago

I have setup event and few listeners in my app which works well.

In my controller, I run all my code inside the score of a transaction. However, there is one listener that executes a query which I want it to be outside of the transaction scope. So it should be executed by itself and should not impact the transaction.

Is this something possible? How?

19th March, 2017

malhayek started a new conversation How Can I Submit Code Improvement Of Laravel To Taylor? • 1 week ago

I have a feature that I wish to add to Laravel which I think will help the community a lot.

I never contributed to someone else project and wish to do that this time.

How can I pull the development version of Laravel 5.5, add my code then send the change to Taylor hoping he will consider adopting this feature?

I am not very good with Git, so I would appreciate some help with the commands.

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

Thank you. What I ended up doing is creating a property that will auto manage this process for me. this is what I have done

in the config\app.php config file I added the following two lines.

    'fallback_in_format' => 'Y-m-d H:i:s',
    'fallback_out_format' => 'd/m/Y H:i A',

Then I created a new base class for my models like the following

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BaseModel extends Model
{
    protected $fixedFormattedFields = null;

    /**
     * Get a plain attribute (not a relationship).
     *
     * @param  string  $key
     * @return mixed
     */
    public function getAttributeValue($key)
    {
        if( ($field = $this->getFieldToFormat($key)) != null)
        {
            return date($field['out_format'], strtotime($this->getAttributeFromArray($key)));
        }

        return parent::getAttributeValue($key);
    }

    /**
     * Set a given attribute on the model.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return $this
     */
    public function setAttribute($key, $value)
    {
        if( ($field = $this->getFieldToFormat($key)) != null)
        {
            $this->attributes[$key] = date($field['in_format'], strtotime($value));

            return $this;
        }

        return parent::setAttribute($key, $value);
    }
    
    /**
     * Get the format property for a given attribute on the model.
     *
     * @param  string  $key
     * @return mix (null|array)
     */
    protected function getFieldToFormat($key)
    {
        foreach($this->getFixedFormattedFields() as $field)
        {
            if($field['key'] == $key)
            {
                return $field;
            }
        }

        return null;
    }

    /**
     * Gets a fields to auto format.
     *
     * @return array
     */
    protected function getFixedFormattedFields()
    {
        if( is_null($this->fixedFormattedFields))
        {
            $this->fixedFormattedFields = [];

            if( property_exists($this, 'formattedDates') && is_array($this->formattedDates))
            {
                foreach($this->formattedDates as $field)
                {
                    if(!is_array($field))
                    {
                        $this->fixedFormattedFields[] = $this->getFixedFormattedField($field);
                        continue;
                    }

                    if(isset($field['key']))
                    {
                        $inFormat = isset($field['in_format']) ? $field['in_format'] : null;
                        $outFormat = isset($field['out_format']) ? $field['out_format'] : null;

                        $this->fixedFormattedFields[] = $this->getFixedFormattedField($field['key'], $inFormat, $outFormat);
                    }
                }
            }
        }

        return $this->fixedFormattedFields;
    }

    /**
     * Get get a standard format for the fields to auto format.
     *
     * @param  string  $key
     * @param  string $inFormat
     * @param  string $outFormat
     * @return array
     */
    protected function getFixedFormattedField($key, $inFormat = null, $outFormat = null)
    {
        return 
        [   
            'key' => $key,
            'in_format' => is_null($inFormat) ? config('app.fallback_in_format') : $inFormat,
            'out_format' => is_null($outFormat) ? config('app.fallback_out_format') : $outFormat
        ];
    }
}

Then in my model I do the following

<?php

namespace App\Models;

use App\Models\BaseModel;

class Expense extends BaseModel
{
    /**
     * Datetime attributes that should be auto manages
     *
     * @var array
     */
    protected $formattedDates = [
                                    [
                                     'key'        => 'paid_at',
                                     'in_format'  => 'Y-m-d H:i:s',
                                     'out_format' => 'd/m/Y H:i A'
                                    ],
                                    'starts_at',
                                    'ends_at'
                                ];

}

As you can see, now all I need to do is define the fields in the $formattedDates property. I can also specify the a different format for each property if I wish.

I hope this helps someone out there.

malhayek left a reply on Where Does Laravel Magically Handle The Mutator And Accessors? • 1 week ago

Thank you very much

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

I apologize, I am not following you. An example will be greatly appreciated.

malhayek started a new conversation Where Does Laravel Magically Handle The Mutator And Accessors? • 1 week ago

So Laravel uses reflection to look for an accessor or mutator method to apply custom logic when accessing a field or before saving the field in the database.

But, in what file in its code does it do this?

My guess is be by utilizing the php's own magic method __get() and __set(). I reviewed the Illuminate\Database\Eloquent class but, I don't see how in there Taylor is checking for the set*Attribute and get*Attribute pattern.

Where can I find the code that handles this?

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

@jlrdw I am trying to find a better way to handle the process of converting string to datetime and datetime to string on accessing or mutating the data without having to write 2 methods per field.

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

@jlrdw that link explains how to create helper methods. Are you saying to create a a global function two function to handle the conversion but still create a getter and setter for each field in each model?


function dateTimeToString($value)
{
    return date('d/m/Y  H:i A', strtotime($value));
}

function stringToDateTime($value)
{
    return date('Y-m-d H:i:s', strtotime($value));
}

Than my model will look like this

    /**
     * Mutate the paid_at to a valid date time
     *
     * @param  string  $value
     * @return void
     */
    public function setPaidAtAttribute($value)
    {
        $this->attributes['paid_at'] = stringToDateTime($value);
    }


    /**
     * Get the paid_at value.
     * @param  string  $value
     * @return string
     */
    public function getPaidAtAttribute($value)
    {
        return dateTimeToString($value);
    }

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

Corrent. If I understand you correctly, your saying to create a global getter and setter. this mean, I would need to hook into each model and for each field of the type datetime, apply a getter and a setter.

malhayek left a reply on What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

Are you saying that getter/setter is the best way to handle this?

How would I know the field type? How would create a global helper?

malhayek started a new conversation What Is The Best Way To Handle The Datetime In Laravel? • 1 week ago

I have models where I need to capture a datetime input from the user. Then I need to store it in the database, and then display it using the proper format.

I am currently handling the process of converting the customer input to a the correct for mat using a mutator. Also, I am using accessor to convert the format from database format to easier to read format.

This is my current code

    /**
     * Mutate the paid_at to a valid date time
     *
     * @param  string  $value
     * @return void
     */
    public function setPaidAtAttribute($value)
    {
        $this->attributes['paid_at'] = date('Y-m-d H:i:s', strtotime($value));
    }


    /**
     * Get the paid_at value.
     * @param  string  $value
     * @return string
     */
    public function getPaidAtAttribute($value)
    {
        return date('d/m/Y  H:i A', strtotime($value));
    }

What is the best way handle this process so I won't have to create a mutator and an accessor for each datetime field?

12th March, 2017

malhayek left a reply on What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

@vipin93 actually I missed an error. I am still getting an error in the command window when I run npm run watch

Here is that I get

 10% building modules 1/1 modules 0 active
Webpack is watching the files.

 95% emitting

 ERROR  Failed to compile with 1 errors                                                                                                                                                       3:37:10 PM


This dependency was not found:

* -!../../../node_modules/css-loader/index.js!./css/custom.css in ./~/css-loader!./~/postcss-loader!./~/resolve-url-loader!./~/sass-loader/lib/loader.js?{"precision":8,"outputStyle":"expanded","source
Map":true}!./resources/assets/sass/app.scss

To install it, you can run: npm install --save -!../../../node_modules/css-loader/index.js!./css/custom.css

malhayek left a reply on What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

@vipin93 I installed the package using npm install eonasdan-bootstrap-datetimepicker

Then in `resources/assets/sass/app.scss I added the followng line.

@import "node_modules/eonasdan-bootstrap-datetimepicker/src/sass/bootstrap-datetimepicker-build.scss";

Does that mean the package will be compiled are ready for me to use including its dependencies? do I need to manually download its dependencies?

Also, usually, to attach the plugin to an element I do something like this

$('.datetime-picker-c').datetimepicker();

Where do I place this code at to attach the plugin?

malhayek left a reply on What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

@ejdelmonico @Cronix this is what I have done trying to use moment.js and https://www.npmjs.com/package/eonasdan-bootstrap-datetimepicker

npm install moment npm install eonasdan-bootstrap-datetimepicker

Then I opened the/resources/assets/js/app.js file and added this window.moment = require('moment');

I am not sure if I am doing this right or not. also how do I include the eonasdan-bootstrap-datetimepicker package so it is compiled?

malhayek left a reply on What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

@vipin93 that fixed that error.

What is the correct way to install bootstrap drop-down menu package? http://eonasdan.github.io/bootstrap-datetimepicker/Installing/ using Laravel's out of the box setup?

malhayek left a reply on What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

Thanks for your help.

I am little confused on how to include external vendor packages. For example, I want to use this package http://eonasdan.github.io/bootstrap-datetimepicker/Installing/ this package hadependencies like jQuery (https://jquery.com/) and Moment (https://github.com/moment/moment)

How to I include these with a fresh Laravel 5.4 installation? Do I manually download the packages?

Finally, when I tried follow the documentation about the setup (https://laravel.com/docs/5.4/mix#introduction) I am running into an error.

I tried installing the dependencies using thenpm install command. then when I try to compiling my assets using npm run dev I get the following errors

> node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

module.js:471
    throw err;
    ^

Error: Cannot find module 'C:\xampp\htdocs\Retailer\node_modules\cross-env\bin\cross-env.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.
js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/s
etup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\xampp\htdocs\Retailer\npm-debug.log


11th March, 2017

malhayek started a new conversation What Is The Right Way To Package All JS And CSS File Under One File In Laravel 5.4? • 2 weeks ago

I always manually included my js or css files into the layout. However, this time I'll like to learn the better method which is combining the JS and CSS files into a single file for the CSS and another for the JS.

I have used Gulp in the past with other languages like ASP.NET so I am familiar with the technique but would like to learn how to use this in Laravel project.

How do I include vendor JS project + custom JS code into one file in my Laravel 5.4 project?

17th February, 2017

malhayek left a reply on Carbon Issue When Compiling The Classes • 1 month ago

@Snapey yes I have the correct class name for my class and it is being called when it should but erroring when I callCorbon::now();

@SaeedPrez I did composer dump-autoload which did not help. However, I have two custom packages that I added to my psr-4 section of my composer.json

Here is how my autoload section looks like

    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Mycorp\\Surveys\\": "Mycorp/surveys/src",
            "Mycorp\\Ahold\\": "Mycorp/demo/src"
        }
    }

malhayek started a new conversation Carbon Issue When Compiling The Classes • 1 month ago

I am trying to use Carbon to update a field with Eloquent.

Here is what I have done. On the very top of my class I did

use \Carbon\Carbon;

Then to use eloquent to set the updated_at field,

$model->updated_at = Carbon::now();

This works fine until I try to compile the classes for production using the following command

php artisan compile

Because I am using the backslash in the use command the compiler is causing an error. I guess I am not supposed to be using the backslash. However, If I don't use the backslash get the following errors.

exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Carbon' not found' in .....

How can I use Carbon class and then compile my classes?

14th February, 2017

malhayek started a new conversation How To Use Eloquent Fluent To Update Records After Joining? • 1 month ago

I am trying to use fluent syntax with eloquent to achieve the same results as the below SQL query would achieve.

UPDATE g SET q.completed = q.completed + 1 FROM [groups] AS g INNER JOIN [quotas] AS q ON q.qid = g.qid WHERE g.iid = 12234

The groups table has a model called group. Also, the quotas table has a model called quota

What is the correct way to join the two model and increment the quota.completed property?

Note, each model point to a different database.

31st December, 2016

malhayek left a reply on Php Artisan Vendor:publish Is Not Doing Anything! • 2 months ago

yes I have. In fact, the composer.json file of that package does composer dumpautoload after the installation or update automatically.

malhayek left a reply on Php Artisan Vendor:publish Is Not Doing Anything! • 2 months ago

I tried that command but still same result. Yes the package has files to be publish. Look at the service provider.

Also look at this link https://github.com/CrestApps/laravel-code-generator or https://packagist.org/packages/crestapps/laravel-code-generator

malhayek started a new conversation Php Artisan Vendor:publish Is Not Doing Anything! • 2 months ago

I am trying to execute php artisan vendor:publish for a specific vendor. But the command keep giving me Nothing to publish for tag [].

I don't understand why this command does not give you better info.

Here is the exact command

php artisan vendor:publish --provider="CrestApps\\CodeGenerator\\CodeGeneratorServiceProvider"

I actually went into CrestApps\\CodeGenerator\\CodeGeneratorServiceProvider and var dumped a message in the boot() method and I got that message. So the correct service provider is being called.

This is the code from my service provider


<?php

namespace CrestApps\CodeGenerator;

use Illuminate\Support\ServiceProvider;

class CodeGeneratorServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {

        $this->publishes([
            __DIR__ . '\\..\\config\\codegenerator.php' => config_path('codegenerator.php'),
        ]);

        $this->publishes([
            __DIR__ . '\\templates' => base_path('resources\\codegenerator-templates\\default'),
        ]);

    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->commands(
            'CrestApps\CodeGenerator\Commands\CreateControllerCommand',
            'CrestApps\CodeGenerator\Commands\CreateModelCommand',
            'CrestApps\CodeGenerator\Commands\CreateIndexViewCommand',
            'CrestApps\CodeGenerator\Commands\CreateCreateViewCommand',
            'CrestApps\CodeGenerator\Commands\CreateFormViewCommand',
            'CrestApps\CodeGenerator\Commands\CreateEditViewCommand',
            'CrestApps\CodeGenerator\Commands\CreateShowViewCommand',
            'CrestApps\CodeGenerator\Commands\CreateViewsCommand',
            'CrestApps\CodeGenerator\Commands\CreateLanguageCommand',
            'CrestApps\CodeGenerator\Commands\CreateFormRequestCommand',
            'CrestApps\CodeGenerator\Commands\CreateRoutesCommand',
            'CrestApps\CodeGenerator\Commands\CreateMigrationCommand',
            'CrestApps\CodeGenerator\Commands\CreateResourceCommand',
            'CrestApps\CodeGenerator\Commands\CreateViewLayoutCommand'
        );
    }
}


I validated that the file/folder that are being copied are correct and exists using scandir() and get_file_content()`

What could be causing this problem? why no files are being copied to the destination?

There is nothing in the laravel log file to also help me here.

30th December, 2016

malhayek left a reply on What Is The Best Laravel 5.1 Generator? • 2 months ago

This one is very flexible and has lots options

https://github.com/CrestApps/laravel-codegenerator

It also have detailed documentation

https://crestapps.com/laravel-code-generator/docs/1.0

26th December, 2016

malhayek started a new conversation How To Deplay Laravel Project On Shared Hosting With Out Changing The Project Folders? • 3 months ago

I am trying to deploy a new Laravel project on a shared hosting. I also would like to keep my Laravel project apps setup the same as if it was on my local machine "standard Laravel setup".

I used FileZilla to transfer all the files from my local machine to the web hosting.

so /public_html contains all of my laravel file and folders.

when I go to mydomain.com I get the provider's default page. and when I go to mydomain.com/public I get a white page.

How can I get laravel app to render when I go to mydomain.com?

25th December, 2016

malhayek started a new conversation What Is A Good Hosting Company? • 3 months ago

Can someone please lead me to a good hosting company where I can host few Laravel base project?

I am looking for a company to allow offer low cost SSL cert.

22nd December, 2016

malhayek left a reply on How Can I Register A New Language Key At Run Time With Laravel? • 3 months ago

The addLines method did the trick!

/**

  • Add translation lines to the given locale.
  • @param array $lines
  • @param string $locale
  • @param string $namespace
  • @return void / public function addLines(array $lines, $locale, $namespace = '') { foreach ($lines as $key => $value) { list($group, $item) = explode('.', $key, 2); Arr::set($this->loaded, "$namespace.$group.$locale.$item", $value); } }

21st December, 2016

malhayek started a new conversation How Can I Register A New Language Key At Run Time With Laravel? • 3 months ago

I wrote a script with Laravel 5.3 that checks if a lang key exists in a giving language at run time. If the key does not exists, it will add it to the file.

However, if the first time around the key does not exists and I add it, then I do another check "during the same request" to see if the key exists, it will say it does not exist. So the loaded languages will not be aware that I added new keys to the file since Laravel loaded the keys in memory and I am only writing to the file on the hard-disk.

when I evaluate the Illuminate\Translation\Translator class I see that the load method checks if a groups is load it does not load it again.

Here is the Laravel Code

/**
 * Load the specified language group.
 *
 * @param  string  $namespace
 * @param  string  $group
 * @param  string  $locale
 * @return void
 */
public function load($namespace, $group, $locale)
{
    if ($this->isLoaded($namespace, $group, $locale)) {
        return;
    }

    // The loader is responsible for returning the array of language lines for the
    // given namespace, group, and locale. We'll set the lines in this array of
    // lines that have already been loaded so that we can easily access them.
    $lines = $this->loader->load($locale, $group, $namespace);

    $this->loaded[$namespace][$group][$locale] = $lines;
}

Is there a way to force Laravel to read the language each time I request? Or, is there a way to add a key to the currently-in-memory keys? How can I tell laravel that I added new keys?

16th December, 2016

malhayek left a reply on Is There A Way To Get The Column Listing With Column Type Using Eloquent? • 3 months ago

@TerrePorter Schema::getColumnType('posts', 'column') giving me the following error

[Symfony\Component\Debug\Exception\FatalErrorException] Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

@Jaytee I am writing a package that need to get info about the table column. Regardless of that driver that the users is using, I will need that info.

malhayek left a reply on Is There A Way To Get The Column Listing With Column Type Using Eloquent? • 3 months ago

@SaeedPrez describe is a MySQL command. I want to be able to do the same thing for all database drives. SqlServer, SqlLite....

malhayek started a new conversation Is There A Way To Get The Column Listing With Column Type Using Eloquent? • 3 months ago

I am trying to get the column listing along with column type, isNullable, default value.

How can I obtain such info using eloquent?

Is this something possible without having to manually execute a select query againstINFORMATION_SCHEMA.COLUMNS table for every supported database driver?

7th July, 2016

malhayek started a new conversation Is It Possible To Cache Only The Relations In Eloquent? • 8 months ago

I have the following code

SurveyInterview::surveyAndCall($this->interview->surveyId, $this->interview->callId) ->with([ 'current_step.page', 'pages' ]) ->first();

How can I cache only the current_step.page and the pages collections?

I tried something like this

    $myInterview = SurveyInterview::surveyAndCall($this->interview->surveyId, $this->interview->callId)
                              ->with([
                                        'current_step.page' => function($query){ $query->remember(180); },
                                        'pages'
                                    ])
                              ->first();

but this gives me an error

Call to undefined method Illuminate\Database\Query\Builder::remember()

6th July, 2016

malhayek started a new conversation How To Cache Records With Eloquent? • 8 months ago

I am trying to understand how to use cache to cache data when using eloquent to reduce the amount of connections/queries to the database.

It is my understanding, when caching a data set using eloquent you can do the following some

User::Where('status','Active')->with('Teams')->remember(3600)->get();

The above code should cache the result for 3600 seconds "Please correct me if I am wrong."

Now, the second time I run the same line of code, will Eloquent automatically pull the records from the the cache or do I have to do a manual check to see if the records exists in the cache then I load it from the cache otherwise execute the above code?

Also, if I have 10 users on the same system and all 10 need the same result set will the data be reloaded from the cache for 9 users? Or will each dataset be associated with one user?

Finally, can I cache the dataset from a raw query using DB::raw?

Does Eloquent store the query and the dataset in the cache so it knows how to search for it in the cache the next time around?

23rd June, 2016

malhayek left a reply on How To Run Multiple Instances Of Laravel On The Same Domain? • 9 months ago

I actually need it like so

Serv1.example.com:8080/dev Serv1.example.com:8080/staging

Each instance is a folder on serv1.example.com

malhayek started a new conversation How To Run Multiple Instances Of Laravel On The Same Domain? • 9 months ago

I have Apache 2.4 running on Windows Server 2012 with PHP 5.6.23 on port 8080.

Assume that the domain to my server is "serv1.example.com" I need to run 3 Laravel instances production,staging and dev using the following links

serv1.example.com:8080/production
serv1.example.com:8080/staging
serv1.example.com:8080/dev

I found another SO questions which seems to be doing the same thing. But when I tried to do the same thing I get the following error

Forbidden

You don't have permission to access /dev on this server.

Here is what I have done so far. In my httpd-vhosts.conf file I added the following VirtualHost

<VirtualHost *:8080>
    ErrorLog "logs/dev-error.log"
    CustomLog "logs/dev-access.log" common
    DocumentRoot "C:\www\dev\public"
    ServerName serv1.example.com
    ServerAlias /dev
    <Directory "C:\www\dev">
        Options Indexes Includes FollowSymLinks MultiViews
        AllowOverride AuthConfig FileInfo Indexes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Then I changed c:\www\dev\public.htaccess the code to the following

<IfModule mod_rewrite.c>
    #Options -MultiViews
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /dev/index.php/?$1 [L]
</IfModule>

What did I do wrong here? how can I access each instance using the same domain?

malhayek left a reply on What Are The Step To Move A Laravel Application Into Production? • 9 months ago

@martinbean Thank you for your input. I have a Windows 2008 R2 Server and I have PHP 5.6.13 running on IIS 7.5. My development environment is basically a different folder on that server. So I have one folder called AppDev "which is where the development environment is running" and "AppProd" which is what is the production environment is running. Since the server is the same, what other steps would I need to do in order to boost performance?

malhayek started a new conversation What Are The Step To Move A Laravel Application Into Production? • 9 months ago

I have an application that I developed using Laravel 5.2. Now I am trying to promote it to production.

What are the best practices to promote the application to production with a solid performance?

Here are the steps that I am thinking that need to take place

  1. Move the new files to the production env.
  2. in the .env file set the following variables APP_ENV=production APP_DEBUG=false CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync and of course the database connection :) Do I need to change the cache_driver, session_driver, queue_driver to boot performance? What else should I do/change to get the most speed at my application?

25th February, 2016

malhayek left a reply on How Can I Setup An Laravel Project On IIS 7.5? • 1 year ago

@willvincent ,

I just changed the Physical Path variable from C:\inetpub\wwwroot\laravel to C:\inetpub\wwwroot\laravel\public

Then when I go to http://localhost/laravel I still get 500 Internal Error

malhayek left a reply on IIS7 Laravel 5 • 1 year ago

I followed all the instruction in the answer but getting ERROR 500 when I go to http://localhost/laravel/public/index.php

Here is what I have done so far http://stackoverflow.com/questions/35640159/how-can-i-setup-an-laravel-project-on-iis-7-5

What could I have done incorrectly?

malhayek started a new conversation How Can I Setup An Laravel Project On IIS 7.5? • 1 year ago

I have a php application that I write using Laravel framework. I developed it using XAMPP server which was running fine.

I want to move it to a production server where I can use IIS 7.5 to manage my applications.

Here is what I have done

I installed IIS
I installed PHP Manager

Created a folder called laravel in C:\inetpub\wwwroot 2. Using PHP Manager I changed the PHP version to 5.6.18 3. In my php.ini of the version 5.6.18 I enabled the following lines

extension_dir = "ext"
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
fastcgi.logging = 0
extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
date.timezone = "ENTER YOUR TIMEZONE HERE"
session.entropy_length = 32

I installed composer with php 5.6.18
I imported the .httaccess file located in the public folder using URL Rewrite Model in IIS. This step created a web.config file. Then I moved it to the public folder.
I converted my Laravel to Application in IIS
I added phpinfo.php file in the root of my laravel all and I was able to see it via the browser.

But I can't access my laravel app.

When I go to http://localhost/laravel/public/index.php I get an error

HTTP 500 Internal error

I followed the blogs below to get where I am at now

http://alvarotrigo.com/blog/installing-laravel-4-in-windows-7-with-iis7/

https://laracasts.com/discuss/channels/general-discussion/iis7-laravel-5?page=2

How can I get laravel app to run?

25th January, 2016

malhayek left a reply on How Do I Implement A "Data Access Layer" And "Business Access Layer" In Laravel 5.2? • 1 year ago

@jlrdw I understand you point. I am trying to wrap my head around the different between the 2 layers and where does laravel implements them.

@akbarkn does that mean that a repository is equevelant to the data access layer?

What is equivalent to the business layer?

24th January, 2016

malhayek started a new conversation Where Do I Implement A Data Access Layer And Business Access Layer? • 1 year ago

In a typical MVC architecture the model is broken in to couple other layers "Data Access Layer" and "Business Access Layer"

How do I implement these 2 layers in Laravel?

13th January, 2016

malhayek left a reply on How To Listen For An Event In Laravel 5.2 • 1 year ago

@premsaurav thank you. I had a typo in the event which is why it never fired!

It worked now

12th January, 2016

malhayek started a new conversation How To Listen For An Event Fired From The Vendor Folder? • 1 year ago

I have a package that fires an event. The event's class that is being fired is called Mikea\Kicker\Events\Interviews\SurveyWasCompleted

I need to listen in for that event and they die and dump the data.

So I added the following code in my routes.php file

Event::listen('Mikea\Kicker\Events\Interviews\SurveyWasCompleted', function($event){
    dd($event);
});

nothing is printed on the screen.

How can I correctly listen for an event to be fired?

malhayek left a reply on How To Trigger A Listener Automatically Once And Event Is Completed. • 1 year ago

@StormShadow
you are right, the way I fire my event like this

Event::fire(new SurveyWasCompleted($this->interview) );

I expect the listener to be triggered once the SurveyWasCompleted is fired.

but if you look at my IncreaseStoreQuota event, it should die and dump the data. But this is not happening

malhayek left a reply on How To Trigger A Listener Automatically Once And Event Is Completed. • 1 year ago

@StormShadow I call the event like this

Event::fire(new InterviewWasSaved($this->myInterview) );

But I need to know how to pass $interview to the listener and how can I call the listener.

malhayek started a new conversation How To Trigger A Listener Automatically Once And Event Is Completed. • 1 year ago

I have 2 packages. The main package is called "surveys" while the other once is called "kicker". Kicker depends on "surveys" to run.

In the "surveys" I fire an event called "SurveyWasCompleted". I need to listen for that events in "kicker" package then I want to run I want to run couple maintenance queries.

Also, I want to pass an object from the event to the listener.

This is how my event class look like

use App\Events\Event; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class InterviewWasCompleted extends Event {

protected $interview;

/**
 * Create the event listener.
 *
 * @return void
 */
public function __construct($interview)
{
    $this->interview = $interview;
}


/**
 * Get the channels the event should be broadcast on.
 *
 * @return array
 */
public function broadcastOn()
{
    return [];
}

}

This is how my listener class look like

namespace Mikea\Kicker\Listeners;

use App\Listeners\Listener; use Rdicorp\Surveys\Tasks\Interviews\SurveyWasCompleted; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue;

class IncreaseStoreQuota extends Listener { /** * Create the event listener. * * @return void */ public function __construct() { dd('IncreaseStoreQuota Listener'); }

/**
 * Handle the event.
 *
 * @param  SurveyWasCompleted  $event
 * @return void
 */
public function handle(SurveyWasCompleted $event)
{
    dd('IncreaseStoreQuota Listener', $event);
    //Define the logic to be executed when an survey was completed
}

}

Then I created an EventServiceProvider for my package like this

namespace Mikea\Kicker\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ 'Mikea\Surveys\Events\Interviews\SurveyWasCompleted' => [ 'Mikea\Kicker\Listeners\IncreaseStoreQuota', ], ];

/**
 * Register any other events for your application.
 *
 * @param  \Illuminate\Contracts\Events\Dispatcher  $events
 * @return void
 */
public function boot(DispatcherContract $events)
{
    parent::boot($events);

}

}

Finally, I load my events service provides by adding the following code to the app.php file

Mikea\Kicker\Providers\EventServiceProvider::class,

7th January, 2016

malhayek left a reply on TokenMismatchExpection When Posting From Inside An Iframe • 1 year ago

@bashy how would I know my setting for iframe? I did not know iframes have settings. I am using IE.

malhayek started a new conversation TokenMismatchExpection When Posting From Inside An Iframe • 1 year ago

I have a page running on http://some.example.com. This page have an iframe. The iframe source/contains a Laravel 5.2 base application.

My Laravel page URL "which is the source of the iframe" is https://laravel.example.com.

https://laravel.example.com has a form with a submit button. When a use clicks it, he/she hits another route on the same domain i.e. https://laravel.example.com/disply/survey

But every time, I submit the form I get the following exception

TokenMismatchException in VerifyCsrfToken.php line 67:

Here is my form

    <form method="POST" action="https://laravel.example.com/disply/survey" accept-charset="UTF-8" class="form">
<input name="_token" type="hidden" value="Dk6SN4WzO4brbvdnBO6JZ7e1lBGjmYz8GQJ1lYFo">
<input name="survey_id" type="hidden" value="10">
<input name="call_id" type="hidden" value="667">
<input name="pools" type="hidden">

<input name="alt_id_1" type="hidden" value="250">
<input name="alt_id_2" type="hidden" value="5">
<input name="alt_id_3" type="hidden">
<input name="alt_id_4" type="hidden">
<input name="alt_id_5" type="hidden">
<input name="alt_id_6" type="hidden">
<input name="alt_id_7" type="hidden">
<input name="alt_id_8" type="hidden">
<input name="alt_id_9" type="hidden">
<input name="alt_id_10" type="hidden">


<input name="alt_string_1" type="hidden">
<input name="alt_string_2" type="hidden">
<input name="alt_string_3" type="hidden">
<input name="alt_string_4" type="hidden">
<input name="alt_string_5" type="hidden">
<input name="alt_string_6" type="hidden">
<input name="alt_string_7" type="hidden">
<input name="alt_string_8" type="hidden">
<input name="alt_string_9" type="hidden">
<input name="alt_string_10" type="hidden">

<div class="text-center"> 
    <input class="btn btn-primary" type="submit" value="Start Survey">
</div>

</form>

What could be causing this issue? How can I correct the problem?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.