mehany

mehany

PHP & JAVA developer at Arizona

Pheonix, AZ

Member Since 3 Years Ago

Experience Points 61,410
Experience
Level
Lessons Completed 330
Lessons
Completed
Best Reply Awards 39
Best Answer
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.

15 Jan
1 year ago

mehany left a reply on To "Repository Pattern" Or Not?

The true answer for your question is "It depends" :) because applications are architected differently. For example you will find this pattern in Hexagonal Architecture.

My own two cents about repos:

Repository Pattern could be used to decouple specific functionality. A Repository that interacts with third party APIs should implement an interface.

I would say, I am on the side of avoiding repositories mostly because I can do so much with Eloquent and queryScopes. But I use repositories when I have a Modal that part of it interacts with third part APIs, something like special management reporting, user tracking, inventory etc... depending on the use case, sometimes I just put the logic in a class and not even repository.

Ex. here is a good use case for repository pattern which is specific to Datatables JS.

10 Jan
1 year ago

mehany left a reply on Show Html In Blade Email

An html email should be something like this https://jsfiddle.net/q9ceu4jL/

09 Jan
1 year ago

mehany left a reply on MassAssignmentException And $guarded Is Set To []

Oh never mind... Just figured it out :)

mehany started a new conversation MassAssignmentException And $guarded Is Set To []

I have a model with two attributes name and description . I get MassAssignmentException while I have $guarded is set to [] am I missing something?

here is my model

class MyModal extends Model
{

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'description'];

    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

}

In my controller I do

    public function store(Request $request)
    {
        //
        $item = MyModal::create($request->input());

        return Response::json($item);
    }

Laravel Framework version 5.3.29

01 Dec
1 year ago

mehany left a reply on Preload A Laravel Page With JS

This is often done with Js and Css. I used this js code before and I liked it, give it a try.

I used it like so , i added right after the <body> tag:

<script type="text/javascript">
      window.loading_screen = window.pleaseWait({
        logo: "/images/logo.svg",
        backgroundColor: '#ffffff',
        loadingHtml: 'Add html here'
      });
    </script>

Then after page loads all content

window.loading_screen.finish();

mehany left a reply on Composer Update Not Install Latest Version

@MGMK are you using dompdf also in your composer.json? if so which version?

29 Nov
1 year ago

mehany left a reply on Laravel On VPS

@LUKAISAILOVIC you seem to have your apache server configuration or apache php module not set properly ( this is for sure because you see files ) if you show some configurations, i may be able to help

mehany left a reply on How To Get All The Images Including The Ones In The Background(css) Of A Site Using Php?

@kobear agree. Doing this with PHP will end up running in several limitations, I would do this with nodeJS and selenium instead. With selenium, you can automatically open a browser, inject scripts to read images, links and possibly grap the link of css files, download them locally then parse them as needed with any language.

09 Jun
2 years ago

mehany left a reply on Import Script From Composer Vendor In Main.js

I see. The only thing I can think of is a syslink

mehany left a reply on Import Script From Composer Vendor In Main.js

I use gulp like this: from where the gulpfile.js ./.. I go back one directory, ./ {pwd}, ./js {pwd}/js

So it goes by current directory. / refers to current directory where gulpfile.js is, same as require('./vendeor_file.js') will expect a file in current directory and require('underscore') for example will look for underscore in the node_modules dir. Have you tried to use './packages/vendor/package/src/js/file.js'?

You wil probably be interested in this blog post

04 Jun
2 years ago

mehany left a reply on LogicException In RouteCompiler

string | 25 len maximum

mehany left a reply on LogicException In RouteCompiler

When i try the code you provided, the router dispatches the action the ::show() method.

mehany left a reply on LogicException In RouteCompiler

Ok thank you! but after that I looked into this, the problem is really making an option available to hook in the same resource name additional methods/actions when needed! Why? because I think that is an elegant syntax! something as the one you suggested Regular Expression Constraints would work as well.

I understand a crud resource is just intended for crud operations but I want to use the same resource name in the url for the index method. Hope this gives you better understanding @SaeedPrez of what I was after. Don't you people think this would be a cool feature?

mehany left a reply on LogicException In RouteCompiler

Well i need crud so that is why I am using resource . Any ways, it looks like it is what it is, I just wish if i can pass to resource more actions. Not sure if this is possible. here is how I solved it earlier

Route::get('documents/list/{product?}', '[email protected]');
Route::resource('documents', 'ManageDocumentsController');

If you ever use Datatables.js along with complex data, you will run into this.

mehany left a reply on LogicException In RouteCompiler

It looks like that does not work with resource.

mehany left a reply on LogicException In RouteCompiler

ok @SaeedPrez, I wish to simply type resource and then it will work with a search parameter! but the router matches {type?} to {id?} so I would like to provide another parameter to list a sub type . To get a better idea here is the controller

public function index(Request $request, $product = null)
            $allPdfs = ($product != null) ?
            PdfDocument::where('pdf_type', '=', $product):
            PdfDocument::select('*');

        $pdfs =   Datatables::of($allPdfs)->make(true);


        if($request->wantsJson())
        {
            return $pdfs;
        }

        return view('admin.documents.index',
            ['page_title' => (($product != null) ?
                    $product : "" ). ' PDF documents List',
             'type'       => $product
            ]);

mehany left a reply on LogicException In RouteCompiler

I think the reason is Route::resource('orders/{type?}' is the same as Route::resource('orders/{id?}' but I am not sure why one would work and the second don't!

mehany started a new conversation LogicException In RouteCompiler

I have an app that has an admin panel. In the admin area Routes I have

    Route::resource('documents/{product?}', 'ManageDocumentsController'); 
    Route::resource('orders/{type?}', 'ManageOrdersController');

So I run this url in my browser ( example.com/admin/orders/download ), I get

Route pattern "/admin/documents/{product}/{{product}}" cannot reference variable name "product" more than once.

I run this url in my browser ( example.com/admin/documents/topo ) it renders the list.

If I switch the order or the route's declaration, it will do the same error. The one that comes after is the one that does not render :(

      Route::resource('orders/{type?}', 'ManageOrdersController');
      Route::resource('documents/{product?}', 'ManageDocumentsController'); 

     Route pattern "/admin/orders/{type}/{{type}}" cannot reference variable name "type" more than once.
28 Apr
2 years ago

mehany left a reply on Can't Connect To Forge MySQL Database From Local Deployment

I assume you have a bash console! The below command will proxy port 3306 ( mysql port ) to your local computer. Then you will be able to use port 33065 and localhost to connect, of course remote DB credentials will be required. You can learn more about this on here.

ssh -L 33065:127.0.0.1:3306 server-ip -l server-user -p ssh-port -N
26 Apr
2 years ago

mehany left a reply on Stub And Publish A Custom Config File

ok, thought there might be a prettier way.

mehany started a new conversation Stub And Publish A Custom Config File

What is a simple way to generate a stub with custom variables?

25 Apr
2 years ago

mehany left a reply on TokenMismatchException In VerifyCsrfToken.php

@Snappy I don't think the per form thing is possible in this case. x-editable appends forms on the fly to allow editing of the area in concern. Additionally, according to the docs, csrf tokens are tied to the session and not the form, so having a valid csrf token in the ajax request is sufficient for Laravel to verify that it is not a bad request.

mehany left a reply on SSL LetsEncrypt Site Not Working On Forge

I didnt use forge for a while now but I know that it could install letsencrypt for you without the need for a tutorial! https://laracasts.com/series/server-management-with-forge/episodes/12

anyways ssh to your server and run sudo nginx -t to check on the configurations, this should tell you what is wrong right away. then cd to /etc/nginx/sites-available and look into the server block for http and https, you should have something like the bellow

server {
  listen 80;
  server_name example.com www.example.com;
  # enforce https
  return 301 https://$server_name$request_uri;
  }

server {
  listen 443 ssl;
  server_name example.com www.example.com;
  root /home/forge/example.com/html/laravel/public;

  ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

hope this helps

mehany left a reply on TokenMismatchException In VerifyCsrfToken.php

No, you should just have one csrf token on the page and check the ajax params for the token, make sure it gets submitted

24 Apr
2 years ago

mehany left a reply on Why Dynamically Mounted Vue Components Does Not Appear In Devtool?

@matiascx this is interesting! Have you tried posting this on Vue forums?

mehany left a reply on Login Form Using Auth

@shanely scroll down a little bit in this class and you will see that username is supported already. You should just change the email field with username

23 Apr
2 years ago

mehany left a reply on How To Parse A Laravel Log

@Ackirb I just looked at this package and the source code seem to be a good place to get inspired.

I don't believe file_get_content was created for this purpose, you may like file instead - since php4

  // from PHP documentations
  $logFile = file(storage_path().'/logs/laravel-2016-04-24.log');
  $logCollection = [];
  // Loop through an array, show HTML source as HTML source; and line numbers too.
  foreach ($logFile as $line_num => $line) {
     $logCollection[] = array('line'=> $line_num, 'content'=> htmlspecialchars($line));
  }
  dd($logCollection);
22 Apr
2 years ago

mehany left a reply on Do You Keep Models And Other Classes In The Same Namespace?

@RoboRobok yeah I do. it helps reduce the size of the hugely expanded file structures. I have seen people leave it in the App namespace and I simply disagree with those. I create a folder with the domain name ( business name ) and I tend to keep every thing related to the business logic within this folder: models, repos, service providers ( singletons ), facades, you name it!

21 Apr
2 years ago

mehany left a reply on Is It Possible To Disable Cache On One View?

@spekkionu that is correct, I just never looked into those cached file.

@premsaurav you were like hah "Where are the views being cached and how?" :)

mehany left a reply on Is It Possible To Disable Cache On One View?

I believe views are cached in storage/framework/views by the framework. The content of the page in concern ( a cart page ) gets updated via Ajax requests from another view and sometimes it does not render the expected content. I am thinking this has to do with the caching mechanism that the framework does! or maybe with the way I render it! I use the cart facade in my view to render the content and I am thinking may be that gets cached! not sure what is the root cause though so I thought of asking if there is a way to disable caching on a specific view since the content of the cart may change during the same session.

mehany started a new conversation Is It Possible To Disable Cache On One View?

I have one view that I don't ever want it to be cached, is there an easy way too achieve this?

17 Apr
2 years ago

mehany left a reply on Tokenmismatchexception Laravel 5.1

@umefarooq so tokenmismatchexception is thrown at all times!?

mehany left a reply on Zip PHP Extension Problem In Ubuntu (PHP7)

The below should install zip extension on your Ubuntu server

 sudo apt-get install php7.0-zip 

Verify from any route with

 dd(get_loaded_extensions());

mehany left a reply on Gulp And Assets

lol sorry but the time you spend trying to figure out why it is not copying is way more than doing it manually

15 Apr
2 years ago

mehany left a reply on Service Provider

why a service provider for this! just add this on the top of your routes file!

 // For development purpose only
 DB::listen(function ($query) {
    \Log::info($query->sql);
 });

mehany left a reply on Blade And Angular Mixing

@willvincent the OP is using a for loop

14 Apr
2 years ago

mehany left a reply on How To Use Blade @stack Syntax ?

@mhankins obviously you have to be confused !! I was looking in the wrong view template that didn't call @push

mehany left a reply on How To Use Blade @stack Syntax ?

@mhankins so how do you include the shared js?

mehany left a reply on How To Use Blade @stack Syntax ?

@mhankins that didn't work! @Mubashar that is what I had before and didn't work.

mehany started a new conversation How To Use Blade @stack Syntax ?

I have a template that shares a global js script that I include at the end of the main layout file. In some templates I want to use javascript on the same file and I want to append after the global js file.

  <body>

    @include('nav.header')

    @yield('content')

    @yield('sidebar')

    @include('scripts.globals') // this renders after, just before body tag

    @yield('scripts') // this renders before scripts.globals

</body>
  

mehany left a reply on How Increase Uploading File Size In Laravel.

Try

   ini_set('memory_limit','256M');
   $file_name = $request->file('myImage');

mehany left a reply on Edited Vagrantfile In Hopes Of Getting My Shared Folers To Sync, Parse Error

syntax error, unexpected end-of-input, expecting keyword_end[/quote] this error means your yaml file has unnecessary tabs or trailing spaces. Often people fall in that trap using a editor that automatically add these stuff. Use nano, vim, phpStorm, notepad++ I think all those editors won't adjust your yaml file on your behave.

13 Apr
2 years ago

mehany left a reply on Blade And Angular Mixing

Try to change either one syntax to avoid conflict!

// example for blade 
Blade::setContentTags('<%', '%>'); // For variables.
Blade::setEscapedContentTags('<%%', '%%>'); // For escaped data.

or

var customInterpolationApp = angular.module('customInterpolationApp', []);

customInterpolationApp.config(function($interpolateProvider) {
   $interpolateProvider.startSymbol('{['); // or change it to something else
   $interpolateProvider.endSymbol(']}'); // or change it to something else
});

https://docs.angularjs.org/api/ng/provider/$interpolateProvider

mehany left a reply on Running Mix.version() Inside Gulp Task

You can keep gulp tasks outside of Elixir and call gulp tasks inside the Elixir object like this

 elixir(function(mix) {
    mix.task('copyHtmlTemplates')
           .version([  /* files */ ])
    });
12 Apr
2 years ago

mehany left a reply on A Good Way To Handle FindOrFail Exception?

so findOrFail return NotFoundHttpException , is there a clean way to handle this exception for a certain model and not all models? For instance in the User model, I would throw UserNotFoundException rather than just NotFoundHttpException . I don't like to wrap my code in try catch, although sometimes I am forced to do so! With try catch I can easily achieve that but correct me if I am wrong about not liking to use Try catch if you think that is a clean approach!