kickthemooon

Hire Me

Experience

20,440

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 124 Lessons Completed
  • 0 Favorites

3rd March, 2018

kickthemooon started a new conversation Dealing With Changes In The Domain Model • 7 months ago

I just realized that I made a "mistake" in my domain model.

The mistake I made was, let's say, I had an Article model and a "relationship property" $file which was a File model so my Article was directly connected to a File but then I realized that I actually needed a model in between, FeaturedImage to hold other properties like $title, $description and whatever else.

My question would be how do you deal with changes in your domain model with regards to migrating those changes in production?

4th February, 2018

kickthemooon started a new conversation Polymorphic OneToMany • 8 months ago

Let's say I have model House and House is built of different Elements like bricks, windows, doors, etc.

Now I imagine having a method on my House model elmentable() and when I call $house->elementable()->toArray() I get an array of different elements like bricks, windows.. with their respective properties or keys in the case of an array.

Unfortunately I'm not sure how to achieve this and if it is or if it is possible.

Any help on how to implement the mentioned use case would be great.

6th January, 2018

kickthemooon started a new conversation How To Abstract Storage Disk Choice For Local And Production Environment • 9 months ago

  • So I setup DigitalOcean Spaces in my app and now I have a choice of disks.

  • Either "local" or "spaces" and I want to abstract it away somehow so that I just use, e.g. Storage::method() without specifying the disk and based on the environment, e.g. development or production, the appropriate disk is used.

I see this in the filesystems configuration...

/*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    /*
    |--------------------------------------------------------------------------
    | Default Cloud Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Many applications store files both locally and in the cloud. For this
    | reason, you may specify a default "cloud" driver here. This driver
    | will be bound as the Cloud disk implementation in the container.
    |
    */

    'cloud' => env('FILESYSTEM_CLOUD', 'spaces'),

I am not sure what "will be bound as the Cloud disk implementation in the container" means.

My question is how do you guys abstract away local/object storage for seamless local development and production?

11th December, 2017

kickthemooon started a new conversation Docker PHPStorm XDebug • 10 months ago

I hope this is not too off-topic but I am trying to get xdebug working with my laravel docker local environment and I am not having much luck.

This is docker-compose.yml:

version: "2.1"

services:

    nginx:
        image: nginx:latest
        ports:
            - 80:80
        volumes:
            - "./public:/var/www/html/public:ro"
            - "./default.conf:/etc/nginx/conf.d/default.conf"
        depends_on:
            - php

    php:
        image: kickthemooon/php-laravel
        expose:
            - 9000
        volumes:
            - ".:/var/www/html"
            - "./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"
        depends_on:
            - mysql

    mysql:
        image: mysql:latest
        ports:
            - 3306:3306
        volumes:
            - data:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
            MYSQL_DATABASE: "${DB_DATABASE}"
            MYSQL_USER: "${DB_USERNAME}"
            MYSQL_PASSWORD: "${DB_PASSWORD}"

volumes:
    data:

This is my dockerfile:

FROM php:7.1-fpm

RUN apt-get update && apt-get install -y \
    && docker-php-ext-install pdo_mysql \
    && rm -rf /var/lib/apt/lists/*

RUN pecl install xdebug-2.5.0 \
    && docker-php-ext-enable xdebug

This is my xdebug.ini:

zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001

My PHPStorm settings:

[[https://i.imgur.com/8AICTCN.jpg|alt=phpstorm_debug_configuration]] [[https://i.imgur.com/kQMYXDb.jpg|alt=phpstorm_remote_debug_configuration]] [[https://i.imgur.com/2GDA69E.jpg|alt=dbgp_configuration]] [[https://i.imgur.com/PAPHOy3.jpg|alt=phpstorm_php_servers_configuration]]

So that's about it.

I would appreciate any hints and tips. Thanks.

23rd November, 2017

kickthemooon started a new conversation How To Compile Additional Sass And Js In With Webpack • 10 months ago

my webpack.mix.js

mix.react('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css');


mix.js('resources/assets/js/publish.js', 'public/js')
    .sass('resources/assets/sass/publish.scss', 'public/css');

my publish.scss

// Bootstrap
@import "~bootstrap-sass/assets/stylesheets/bootstrap";

// AdminLTE Template
@import "~admin-lte/dist/css/AdminLTE.min.css";

// FontAwesome
@import "~font-awesome/scss/font-awesome.scss";

my publish.js

require('./bootstrap');

require('admin-lte/dist/js/adminlte.js');

My additional assets beside app.js and app.scss are not being compiled.

How to add additional assets to webpack.mix.js?

21st November, 2017

kickthemooon left a reply on House Polymorphic Relation With Elements (bricks, Windows, Doors) • 11 months ago

I already read that but maybe I am not bright enough because I don't know how to apply it to my example based on the documentation example.

In the documentation example following things can be called:

$post->tags
$video->tags
$tag->videos

I don't see something like $house->getElements() where elements can be different objects

But I probably got something mixed up anyways :)

kickthemooon started a new conversation House Polymorphic Relation With Elements (bricks, Windows, Doors) • 11 months ago

E.g. I have a Model House and I want to have a many to many relation with Elements which could be bricks, windows doors or other elements. And when I call a method, e.g. getElements() on a House object I want to get all of the elements whether they are bricks, windows or doors.

Is this possible with Eloquent?

22nd June, 2017

kickthemooon started a new conversation Laravel IDE Helper Support For Traits • 1 year ago

I wanted to ask if anyone has a advice on how to generate the ide helper for the methods of traits like when you use packages like entrust or spaties packages and add their traits to the user model...

I have the laravel ide helper package but not sure how to make it support the traits...

9th March, 2017

kickthemooon left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

@egarcia i read somewhere that unset destroys only the reference but doesnt quite clear the memory, thats why i added both. and im not sure what the difference between ${variable} = null and calling the the variable directly in this code i posted?

kickthemooon left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

at the end of each iteration I added:

$featuredImage = null;
$libraryImage = null;
$article = null;
unset($featuredImage);
unset($libraryImage);
unset($article);

the script looks like this now:

public function handle()
    {
        Article::where('index_block_position', 0)->orderBy('created_at', 'desc')->each(function($article){
                if($article->featured_image != ''){
                    try{
                        $featuredImage = $this->mediaLibrary->addMediaFromUrl($article, 'http://avaz.ba' . $article->featured_image, 'featured_image');
                        $libraryImage = $this->mediaLibrary->addMediaFromUrl(MediaLibrary::first(), 'http://avaz.ba' . $article->featured_image);
                        $article->index_block_position = 1;
                        $article->save();
                        $this->info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                        Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                        Log::info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                    }catch (\Exception $e){
                        $this->info("image: {$article->featured_image} - exception: {$e->getMessage()}");
                        Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                        Log::info($e->getMessage());
                    }
                }
                $featuredImage = null;
                $libraryImage = null;
                $article = null;
                unset($featuredImage);
                unset($libraryImage);
                unset($article);
        });
        $this->info('All done!');
    }

kickthemooon left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

@bashy Not sure where its leaking.

Could you give me and example "cleared upon completion" of one iteration

kickthemooon left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

@martinbean can I do something like this:

Article::where('index_block_position', 0)->each(function($article){
            if($article->featured_image != ''){
                try{
                    $featuredImage = $this->mediaLibrary->addMediaFromUrl($article, 'http://avaz.ba' . $article->featured_image, 'featured_image');
                    $libraryImage = $this->mediaLibrary->addMediaFromUrl(MediaLibrary::first(), 'http://avaz.ba' . $article->featured_image);
                    $article->index_block_position = 1;
                    $article->save();
                    $this->info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                    Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                    Log::info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                }catch (\Exception $e){
                    $this->info("image: {$article->featured_image} - exception: {$e->getMessage()}");
                    Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                    Log::info($e->getMessage());
                }
                $featuredImage = null;
                $libraryImage = null;
                $article = null;
            }
        });

where I set the variables to null:

$featuredImage = null;
$libraryImage = null;
$article = null;

kickthemooon left a reply on Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

@martinbean thanks for the suggestion. I understand the memory is full quickly.

"Clear up variables, file handles, etc after you’ve used them." Not sure how to implement this..

An example would be appreciated.

kickthemooon started a new conversation Allowed Memory Size Of 134217728 Bytes Exhausted • 1 year ago

I am trying to import around 130k images via url. I thought it would be convenient to write a cli artisan command.

This is my script:

public function handle()
    {
        Article::where('index_block_position', 0)->each(function($article){
            if($article->featured_image != ''){
                try{
                    $featuredImage = $this->mediaLibrary->addMediaFromUrl($article, 'http://myoldwebsite.com' . $article->featured_image, 'featured_image');
                    $libraryImage = $this->mediaLibrary->addMediaFromUrl(MediaLibrary::first(), 'http://myoldwebsite.com' . $article->featured_image);
                    $article->index_block_position = 1;
                    $article->save();
                    $this->info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                    Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                    Log::info("Article {$article->id} image: {$featuredImage->id} - Library image: {$libraryImage->id} - added");
                }catch (\Exception $e){
                    $this->info("image: {$article->featured_image} - exception: {$e->getMessage()}");
                    Log::useDailyFiles(storage_path().'/logs/featured-image-migration.log');
                    Log::info($e->getMessage());
                }
            }
        });
        $this->info('All done!');
    }

Unfortunately, after 10 or so images added I get the following error:

Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 134217728 bytes exhausted (tried to allocate 24576 bytes)

I am not sure how i can make this work because i have 130k images to import and the memory limit of 128M is already exhausted after 10 images...

I would appreciate suggestions.

23rd February, 2017

kickthemooon started a new conversation Call To Undefined Method Laravel\Scout\Builder::skip() • 1 year ago

I am trying to implement search with load more button instead of pagination.

Unfortunately it seems that scout has only the take() method but no skip() method?

I am searching for ideas, any suggestions?

7th February, 2017

kickthemooon started a new conversation Adding Additional Data To Search / Elasticsearch • 1 year ago

I have an Article model. The article model has elements that can be attached to the Article.

It's a one to many relationship. The elements have an Article id.

The element has a text field which I would like to add to Elasticsearch.

Unfortunately I am not sure how to do that.

10th January, 2017

kickthemooon left a reply on All Posts From All Subcategories • 1 year ago

@rcubitto the example with the User model is a post on twitter from taylor otwell. it kinda looks like something i would need but I am not sure if I can use it on an object. something like:

$category->has('subcategories.articles')->get()
  1. users adding articles cannot select a top category thats why no article is ever attached to a top category.

  2. News is a top category and has no articles attached to it directly.

  3. When a visitor clicks on the menu item "news" which represents the news category i need to get all the articles from all the subcategories.

so the tree goes something like this: News

  • Domestic
  • Regional
  • World

Sports

  • Football
  • Basketball
  • Tennis

so when someone navigates to news i need the articles from all its subcategories in the case of the news category it would be all the articles from domestic, regional, world. In the case of sports it would be all the articles from football, basketball, tennis.

9th January, 2017

kickthemooon started a new conversation All Posts From All Subcategories • 1 year ago

this is my category model:

class Category extends Model
{
    ...
    public function parentcategory() {
        return $this->belongsTo('App\Category', 'category_id');
    }

    public function subcategory() {
        return $this->hasMany('App\Category');
    }

    public function articles() {
        return $this->belongsToMany('App\Article');
    }
    ...
}

so I am using this kind of a relationship for the purpose of potential unlimited sub category levels

this is my article model:

class Article extends Model implements HasMediaConversions
{
    ...
    public function categories() {
        return $this->belongsToMany('App\Category');
    }
    ...
}

I am never attaching articles to top level categories (categories that dont have any parent categories).

So I cannot do this $category->articles if the $category is a top level category.

What i need is all the articles from all the sub categories...

I am not sure if taylors recent tweet is related to this:

User::has('posts.comments')->get();

15th December, 2016

kickthemooon left a reply on Redis And Pagination • 1 year ago

I was trying to get redis and laravel going with phpredis and the vetruvet/laravel-phpredis package.

Things didn't really want to go as expected.

Cache::remember and other Cache methods were giving me false.

Switched over to tillkruss/laravel-phpredis

PHPRedis and Laravel work great now.

13th December, 2016

kickthemooon left a reply on Redis And Pagination • 1 year ago

@willvincent $articles->render() is working in an other case for me except with redis as shown above.

$articles->links() throwing the same error.

Call to undefined method stdClass::links()

kickthemooon started a new conversation Redis And Pagination • 1 year ago

I am starting off with redis. This is my controller:

public function index(){

        $currentPage = Input::get('page') ? Input::get('page') : '1';

        $articles = $this->remember('articles.paginate.'.$currentPage, 3, function(){
            return json_encode(Article::orderBy('id', 'desc')->with('categories')->paginate(20));
        });

        return view('index')->with(compact('articles'));
    }

    public function remember($key, $time, $callback){
        if($value = LRedis::get($key)){
            return json_decode($value);
        }

        LRedis::setex($key, $time, $value = $callback());

        return json_decode($value);
    }

and this is my view:

@foreach($articles->data as $article)
            <div class="row">
                <div class="col-sm-12">
                    <a href="/article/{{ $article->id }}"><h3 class="title">{{ $article->title }}</h3></a>
                    <p class="text-muted">
                        @foreach($article->categories as $category) <a href="/category/{{ $category->id }}">{{ $category->name }}</a> @endforeach
                    </p>
                    <p>
                        {{ $article->content }}
                    </p>
                </div>
            </div>
            <hr>
        @endforeach

        <div class="pull-right">
            {{ $articles->render() }}
        </div>

The render method for pagination is not working and I am getting this error:

Call to undefined method stdClass::render() 

This is my $articles die and dump:

{#198 ▼
  +"total": 11683
  +"per_page": 20
  +"current_page": 1
  +"last_page": 585
  +"next_page_url": "http://redis.dev?page=2"
  +"prev_page_url": null
  +"from": 1
  +"to": 20
  +"data": array:20 [▶]
}

I would be interested in some suggestions or solutions for the pagination part

8th December, 2016

kickthemooon started a new conversation Redis Caching Spatie Media Library • 1 year ago

So I am starting to implement Redis in my app. I am new to redis. My app uses Spatie Media Library.

The scenario:

Article.php has many Element.php
Element.php is using SpatieMediaLibrary to attach media to it
Element.php has one Gallery.php
Gallery.php is using SpatieMediaLibrary to attach media to it

On the front-end i am doing this:

@foreach($article->elements as $element)
    //This part will access the database directly
    @foreach($element->getMedia()->first() as $image)
         //displaying single image
    @endforeach
@endforeach

and...

@foreach($article->elements as $element)
    //This part will access the database directly
    @foreach($element->gallery->getMedia() as $image)
         //displaying gallery images
    @endforeach
@endforeach

Article elements caching is fine, now I'm not sure how to cache the..

$element->getMedia()->first()
and
$element->gallery->getMedia()

part with redis so I do not call the database every time.

Any suggestions ideas? Thanks.

30th November, 2016

kickthemooon left a reply on Wamp / Laravel 5.3 / Postgres Pdo Exception Could Not Find Driver • 1 year ago

@JhumanJ not sure how or what i did, but after hours it started to work finally. I think the thing that got it to work is the php path in my windows path variable. I think it was not right. Now i dont know if mac has something like this path variable.

7th November, 2016

kickthemooon left a reply on Only /dashboard Route Redirects To /dashboard/ • 1 year ago

The solution was obvious. I just missed it.

I had a folder under the public folder with the same name as my route and the .htaccess clearly states:

# Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

So if anyone else comes across this issue just check that you dont have folder under the public that has the same name as a route.

kickthemooon left a reply on Only /dashboard Route Redirects To /dashboard/ • 1 year ago

it is happening on wamp and IIS on three different machines locally, its very crazy :(

kickthemooon started a new conversation Only /dashboard Route Redirects To /dashboard/ • 1 year ago

So I have a route:

    Route::get('dashboard', 'Dashboard\[email protected]');

And when I try to open this route a trailing slash is added and I am being redirected to a 404 error. this: /dashboard becomes this /dashboard/

And the strangest thing is that is happening with ONLY the dashboard route, All other routes are working just fine.

    Route::get('dashboard/users', 'Dashboard\[email protected]');
    Route::get('dashboard/users/create', 'Dashboard\[email protected]');
    Route::post('dashboard/users/create', 'Dashboard\[email protected]');
    Route::get('dashboard/users/edit/{id}', 'Dashboard\[email protected]');
    Route::post('dashboard/users/edit/{id}', 'Dashboard\[email protected]');
    Route::get('dashboard/users/delete/{id}', 'Dashboard\[email protected]');

all these and all other routes work fine

did anybody have a similar issue? any suggestion is welcome

6th November, 2016

kickthemooon started a new conversation Wamp / Laravel 5.3 / Postgres Pdo Exception Could Not Find Driver • 1 year ago

I am having a hard time setting up laravel 5.3 (running on wamp/windows) with pgsql. I am getting an error "PDO Exception - Could not find driver" when I am trying to migrate tables with "php artisan migrate"

  1. I installed postgres 9.6.
  2. I enabled the php extensions for postgresql: [php-info-pgsql]: http://imgur.com/YsOe0sv "php-info-pgsql"
  3. I added postgres libraries to environment path variable [pg-path-variable]: http://imgur.com/nn2B4D0 "pg-path-variable"
  4. I tested the pdo postgres connection with php and I am getting connected:
$dbh = new PDO("pgsql:dbname=rotocms;host=127.0.0.1", "postgres", "sploit190");

if($dbh) {
   echo 'connected';
} else {
    echo 'there has been an error connecting';
} 

So I am stuck, cant get the migration to work in laravel. My .env:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=mydatabasename
DB_USERNAME=postgres
DB_PASSWORD=password

Any suggestions are welcome

30th October, 2016

kickthemooon left a reply on ForEach With Every 10th And 2nd Changes • 1 year ago

@JackRobertson yap, thanks. just didnt use the chunks before so had to take a better look and it seems just too easy lol so i thought come on, this is it? haha

kickthemooon left a reply on ForEach With Every 10th And 2nd Changes • 1 year ago

@JackRobertson I am just not sure so I'll ask.. What if there are 50 items in the collection? will this only do the 10 or will it go through all the 50 and chunking by 10? just a bit confusing...

kickthemooon left a reply on ForEach With Every 10th And 2nd Changes • 1 year ago

@JackRobertson Looks great, will try it immediately, thanks

kickthemooon started a new conversation ForEach With Every 10th And 2nd Changes • 1 year ago

So i am dealing with coupons that I need to print. I prepared the view and I am passing coupons to the view:

public function printSelected($ids){
        $couponIDs = explode(',', $ids);
        $selectedCoupons = Coupon::find($couponIDs);

        return view('admin.coupons.print')->with(compact('selectedCoupons'));
    }

Now I need to loop through them in a certain manner.

  1. every 10 coupons I need a new "page" block because 10 coupons fit into a page block
  2. every second coupon I need a new table row because 2 coupons or table data fits into one row
<div class="coupons">
    <div class="page">
        <div class="subpage">
            <table>
                <tr>
                    <td>
                        <span class="coupon">{{ $coupon->code }}</span><br>
                        <hr>
                        <span class="name">{{ $coupon->user->name }}</span>
                    </td>
                    <td>
                        <span class="coupon">{{ $coupon->code }}</span><br>
                        <hr>
                        <span class="name">{{ $coupon->user->name }}</span>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

Any ideas? Help is appreciated.

31st August, 2016

kickthemooon started a new conversation Seo Friendly Filter Routes • 2 years ago

So I have a Designer.php model and I would like the users to be able to filter designers by city and / or service with seo friendly urls.

Route::get('designers/{city}', 'Front\[email protected]');
Route::get('designers/{service}', 'Front\[email protected]');
Route::get('designers/{city}/{service}', 'Front\[email protected]');

How do you approach this? Whats working for you?

20th June, 2016

kickthemooon left a reply on Factory Method Pattern DB Object Instantiation? • 2 years ago

@spekkionu great reference. I'm trying to find my way through it.

One basic question - What class / interface out of list will be used throughout the app?

the ConnectorInterface?

kickthemooon started a new conversation Factory Method Pattern DB Object Instantiation? • 2 years ago

I am trying to grasp the factory design pattern in PHP. It is very hard doing so with the usual automobile, animal, etc. examples.

I would like to try and grasp it through a real life problem of concrete database object instantiation.

So my first question would be: How would a UML diagram for this problem look like? What would be the necessary classes / interfaces ?

class Database class DatabaseFactory class Mysql class Postgresql ?

Any help / suggestion / reference is welcome.

2nd June, 2016

kickthemooon left a reply on Best Practice For Handling "active" Menu Item In L5 • 2 years ago

I am solving it by passing variables from my controllers.

public function index(){
        $data=array('menuParent'=>'Users', 'menuChild'=>'viewUsers');
        $users=User::all();
        return view('admin.users.index', $data)->with(compact('users'));
    }

view

<li class="treeview @if(isset($menuParent)) {{ ($menuParent=='Users') ? 'active' : '' }} @endif">
                <a href="#">
                    <i class="fa fa-user"></i> <span>Users</span>
                    <i class="fa fa-angle-left pull-right"></i>
                </a>
                <ul class="treeview-menu">
                    <li @if(isset($menuChild)) {{ ($menuChild=='viewUsers') ? "class=active" : "" }} @endif>
                        <a href="/admin/users"><i class="fa fa-circle-o"></i> Users overview</a>
                    </li>
                    <li @if(isset($menuChild)) {{ ($menuChild=='addUser') ? "class=active" : "" }} @endif>
                        <a href="/admin/user/add"><i class="fa fa-circle-o"></i> Add User</a>
                    </li>
                </ul>
            </li>

31st May, 2016

kickthemooon left a reply on Is This Something I Can Share On GitHub? • 2 years ago

@bashy so composer install will get them the vendor folder?

Ok thanks a lot. I'll update it the way you suggested.

kickthemooon left a reply on Is This Something I Can Share On GitHub? • 2 years ago

@EmilMoe All the credits are there, I didn't change anything that I was supposed to change.

Now about the vendors, I noticed that it shouldn't be included but how will something get the vendor folder when they try to set it up on their end?

Sorry never did this before thats why im posting it here...

kickthemooon started a new conversation Is This Something I Can Share On GitHub? • 2 years ago

So I made my first repository on GitHub. It is a "Laravel base app" with user access management, user email verification and admin panel. It uses Zizaco/entrust plus the permissions have an additional field/property, "route" and authorize middleware. So users get a 403 permission denied if their role doesn't have the permission to access a certain route.

Visit https://github.com/kickthemooon/LaravelBaseApp

I wanted to ask if this is ok as a repository to share and have on GitHub?

28th May, 2016

kickthemooon left a reply on API Back-end / Web Front-end? • 2 years ago

@malfait.robin hitting two birds with one stone, having the back-end with an API ready for anything to use it (web, mobile), sounds awesome definitely.

The cool thing is when you want to change something on the back-end just do it, keep the API working and the front-end would be the same as well.

The coolness level of this depends on how well you design your API, right?

kickthemooon started a new conversation API Back-end / Web Front-end? • 2 years ago

So a couple of days ago I saw a project using this technique for a larger news magazine and now I'm a bit curious about this and want to ask...

Anybody using this technique / pattern? Why did you choose it? What kind of projects did you use it for? What were the benefits for you? What are potential downsides?

12th May, 2016

kickthemooon left a reply on Wamp64, PHP7, Laravel 5.2, Tmp Folder Doesn't Store Files • 2 years ago

@Prez Ok I am using spatie/laravel-medialibrary and this is my controller

$images = $request->file('reportimages');

        foreach($images as $image){
            $image = $image->move('C:\tmp');
            $report->addMediaFromRequest($image)->toCollection('medical-reports');
        }

Now since i am moving the file to c:\tmp it appears there, so it is moved successfully but I still get this error

FileCannotBeAdded in FileCannotBeAdded.php line 49:
The current request does not have a file in a key named `C:\tmp\phpE5B.tmp`

here is the the media-library method

public static function createFromRequest(Model $subject, string $key)
    {
        if (!request()->hasFile($key)) {
            throw FileCannotBeAdded::requestDoesNotHaveFile($key);
        }

        return static::create($subject, request()->file($key));
    }

kickthemooon left a reply on Wamp64, PHP7, Laravel 5.2, Tmp Folder Doesn't Store Files • 2 years ago

@Prez I am sorry boss, you are very right, I will try something...

kickthemooon left a reply on Wamp64, PHP7, Laravel 5.2, Tmp Folder Doesn't Store Files • 2 years ago

@Prez

Fatal error: Call to a member function move() on array

Its a multiple file upload...

kickthemooon left a reply on Wamp64, PHP7, Laravel 5.2, Tmp Folder Doesn't Store Files • 2 years ago

@christopher "image in the tmp folder I am on windows and I granted all permissions for all users for the tmp folder."

kickthemooon started a new conversation Wamp64, PHP7, Laravel 5.2, Tmp Folder Doesn't Store Files • 2 years ago

So im using wamp64 with php7 im trying to upload images. my form looks likes this:

<form  method="POST" action="/dashboard/nalaz/dodaj/{{ $patients->id}}" enctype="multipart/form-data">
    <input type="file" name="images[]">
</form>

this is my php.ini file uploads configuration

file_uploads = On
upload_tmp_dir ="C:/wamp64/tmp"
upload_max_filesize = 3M
max_file_uploads = 5

Now i do this in my laravel controller

$temp = tmpfile();
$images = $request->file('reportimages');
dd($images);

dd() gives me the array of uploaded files

array:1 [▼
  0 => UploadedFile {#363 ▼
    -test: false
    -originalName: "11082663_10205108991016758_689124932158641809_n.jpg"
    -mimeType: "image/jpeg"
    -size: 42149
    -error: 0
    path: "C:\wamp64\tmp"
    filename: "php95FE.tmp"
    basename: "php95FE.tmp"
    pathname: "C:\wamp64\tmp\php95FE.tmp"
    extension: "tmp"
    realPath: "C:\wamp64\tmp\php95FE.tmp"
    aTime: 2016-05-12 10:21:16
    mTime: 2016-05-12 10:21:16
    cTime: 2016-05-12 10:21:16
    inode: 0
    size: 42149
    perms: 0100666
    owner: 0
    group: 0
    type: "file"
    writable: true
    readable: true
    executable: false
    file: true
    dir: false
    link: false
    linkTarget: "C:\wamp64\tmp\php95FE.tmp"
  }
]

but NOTHING gets written to "C:/wamp64/tmp" so it cannot actually save the immage because there is no image in the tmp folder I am on windows and I granted all permissions for all users for the tmp folder.

24th April, 2016

kickthemooon left a reply on Additional Pivot Column Storing/retrieving • 2 years ago

To store something to an additional pivot field use this in your controller method:

$user->raltionshipName()->attach($relationShipId, array('field_name' => 'information you want to store to the field'));

kickthemooon started a new conversation User As Supporter For Campaign • 2 years ago

The models are:

Campaign
User

User can publish campaigns so the user can be a publisher
but the user can also be a voter to a campaign.

So I need a many to many relationship for the Campaign model and User model and I need an additional field which will be a comment that a user can leave with the vote:

campaign_id user_id comment

So I am not sure how I would handle storing the additional comment field inside the pivot table?

17th April, 2016

kickthemooon started a new conversation Campaigns - Supporters, Relationship? • 2 years ago

So I am developing a platform similar to change.org.
So I have campaigns that people can publish and then gather supporters/votes.
so two models:
Campaign
Supporter
( beside the other models like user )

The supporter has the fields name, last name, email, state, city.

Now as I see it, this is a one to many relationship. One campaign has many supporters, support/vote belongs to campaign.

But I would like to restrict one email ( supporter/vote ) per campaign so a user cannot vote more then once for a campaign...

Do you think this is ok? Anybody worked on something similar? any suggestions?

7th April, 2016

kickthemooon left a reply on Xml Parsing • 2 years ago

$xml_leagues = $xml->parser([
    'data' => ['uses' => 'Country[Competition::id>id,Competition::name>name,Competition::event_name>event_name]', 'default' => null],
]);

Edit Your Profile
Update

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