katifrantz

Web Developer at Self - Freelancer

Hire Me

Experience

25,330

24 Best Reply Awards

  • Member Since 1 Year Ago
  • 148 Lessons Completed
  • 0 Favorites

5th July, 2017

katifrantz left a reply on MYSQL - DATETIME SAVED TO DATABASE AUTOMATICALLY BACKDATES AFTER A FEW MINUTES TO CURRENT DATE AND TIME • 1 month ago

Hey, @chrisebner I did what you asked, by adding return $task, and strangely, it returns the $task object as a json, and this time around, the deadline field stays unchanged. That's really strange, but How can this be explained please ?

katifrantz left a reply on MYSQL - DATETIME SAVED TO DATABASE AUTOMATICALLY BACKDATES AFTER A FEW MINUTES TO CURRENT DATE AND TIME • 1 month ago

This is all done with Laravel, and it looks something like this:


public function saveTask() {
    $task = Task::create([
        //other stuff
        'deadline' => '2017-02-13 11:00:00'
    ]);
}

There is a field called published, and is by default 0. When I create task, all works fine. But when I call the publish method to publish task, it goes crazy and backdates to today's date.


public function publishTask($id) {

    $task = Task::find($id);
    
    $task->published = 1;
    $task->save();

    return redirect()->back();

}

At this point, as soon as I call the publishTask method, on page refresh, database entry for deadline changes to today's date, and the task is published.

That's all I got. Okay, gladly welcoming any ideas. Thanks y'allz for your time

4th July, 2017

katifrantz left a reply on MYSQL - DATETIME SAVED TO DATABASE AUTOMATICALLY BACKDATES AFTER A FEW MINUTES TO CURRENT DATE AND TIME • 1 month ago

Thing is, it works PERFECTLY ON MY LOCAL MACHINE . PERFECTLY . No problems at all.

I'm saving the date as datetime.

I used MYSQL command line to check out database, it saves correctly, and then later updates.

I feel better now knowing the error might be coming from my code, means its fixable.

But I don't know , ALL DATETIME fields in my database behave like this, and I can't have errors everywhere .

Any ideas ?

Thanks

:)

katifrantz started a new conversation MYSQL - DATETIME SAVED TO DATABASE AUTOMATICALLY BACKDATES AFTER A FEW MINUTES • 1 month ago

Hey Guys

So I have this Laravel app I just deployed to production, and when I maybe create a schedule, it records the correct time and date for that task to the database, but after a few minutes, the time and date automatically change to today's date. Its crazy, but I don't know whatz going on. Google, for the first time didn't help me. Maybe it's because I have no idea what is going on. Any ideas ? Thanks for any contributions

14th April, 2017

katifrantz left a reply on Private Method Cannot Access 'this' Keyword • 4 months ago

@topvillas actually, it will. But this does not affect the question . Please what else do you think ?

katifrantz left a reply on Private Method Cannot Access 'this' Keyword • 4 months ago

@jlucia the promise automatically knows to pass the error to this method.

13th April, 2017

katifrantz started a new conversation Private Method Cannot Access 'this' Keyword • 4 months ago

I'm working on an ES6 project , and I am calling a private method as an error handler on an ES6 class, but when I try to access some properties on the class itself inside the error handler, I get an error.


class Service {
    message = ''

    getData() {
        return this.http.get(url)
                     .then((data) => {
                        //handles success
                     })
                     .catch(this.handleError)
    }
    private handleError(error) {
        this.errorMessage = error.message
        // I get an error saying --> cannot read property message of undefined  
    }
}

This project is an angular 4 project, and I am building with TypeScript. Any Ideas are gladly accepted and appreciated. Thank you.

10th April, 2017

katifrantz started a new conversation Writing Nodejs Completely In ES6 • 4 months ago

I've been thinking about this for a while. Nodejs (The latest versions) support ES6 out of the box. Does this mean I can write all of my node code in ES6 and deployas it is without the use of any babel or webpack stuff (without transpiling to vanilla javascript)? I personally think yes, because on production this code is only gonna run on the server anyway, so all I need to do is install a later version of nodejs which supports es6 and everything will work fine. What do you think ? Thanks for sharing your thoughts on this.

17th January, 2017

katifrantz left a reply on UPDATED IN LARACASTS FORUM • 7 months ago

@DarkRoast makes a lot of sense. thank you !

katifrantz started a new conversation UPDATED IN LARACASTS FORUM • 7 months ago

Hey guys, anyone knows how @jeffrey_way implemented the "UPDATED" in the forums ? it marks a discussion as updated if a user hasn't yet viewed the latest changes.

katifrantz left a reply on Inside Component Unable To Assign Retrieved Data To Variable • 7 months ago

Can you please use markdown to present your code cleanly ? Cant see a thing.

katifrantz left a reply on HOW DOES FORGE REALLY WORK ? • 7 months ago

@w1n78 Thanks again. I understand what the bash script does, i have experience in setting up and managing linux servers. I was actually interested in some code that would run this script on another server . I think i have a pretty rough idea about how it works, using laravel envoy. But I just wanted to get others' opinions. So thanks for your input ;)

14th January, 2017

katifrantz left a reply on HOW DOES FORGE REALLY WORK ? • 7 months ago

@w1n78 thank you very much for this response. can you go deeper please ? from what i understand now, i can say forge has an api, when its called, a php method runs a bash script on the server, then broadcasts the results. Can you go deeper on how the process works ? thank you again for this insight

11th January, 2017

katifrantz left a reply on Protect Api • 7 months ago

I don't really understand your question, but if you are trying to allow only particular domains from making url calls to your API, simply make a middleware in your laravel app that gets the domain from which the incoming request is being sent, and if this matches any permitted domains, then the request can be processed . if not, do not process the request, send back an error , or whatever.

7th January, 2017

katifrantz left a reply on HOW DOES FORGE REALLY WORK ? • 7 months ago

@ohffs Makes a lot of sense . Looking into all that right now. Any more ideas would be appreciated. Thank you.

katifrantz left a reply on HOW DOES FORGE REALLY WORK ? • 7 months ago

@ohffs true. . . Please do you care to elaborate more ? For example, where does forge live ? On a server, right ? So this server SSH-es into the newly created DO droplet and runs commands? What programming language tells it to do this ? PHP ? how ? thanks for your reply . ;)

katifrantz started a new conversation HOW DOES FORGE REALLY WORK ? • 7 months ago

How does forge really work? How does it run apt-get commands on digital ocean servers ? It's written in PHP, or Laravel i suppose. I know it communicates through DO API, but the api only gives permission to create droplets and stuff like that. But how does it install nginx , mysql and all that on the droplet ? ANY IDEAS ARE MOST HIGHLY WELCOME !

3rd January, 2017

katifrantz left a reply on Regarding API Authentication And Javascript Application • 7 months ago

What type of app are you building ? It should surely be SPA, if you want to consume Passport with JS .

If your app is SPA , then this youtube help you out. But make sure you actually need passport before using it.

katifrantz left a reply on .env File Not Hidden From Github. • 7 months ago

Please show us your .gitignore file, and did you dd this line to your .gitignore before or after your initial commit ?

31st December, 2016

katifrantz started a new conversation Vueify Not Working On Fresh Laravel Install • 7 months ago

Hello guys . I get this error on fresh laravel install . Any ideas why ?


<template>
^
ParseError: Unexpected token
[18:35:31] Finished 'browserify' after 924 ms
[18:35:31] Finished 'all' after 926 ms
[18:35:31] Starting 'default'...
┌──────────────────┬─────────┬────────────────────────────┬──────────────────┐
│ Task             │ Summary │ Source Files               │ Destination      │
├──────────────────┼─────────┼────────────────────────────┼──────────────────┤
│ mix.browserify() │         │ resources\assets\js\app.js │ public\js\app.js │
└──────────────────┴─────────┴────────────────────────────┴──────────────────┘
[18:35:31] Finished 'default' after 6.59 ms


22nd December, 2016

katifrantz left a reply on View Sharing , Laravel 5.3 • 7 months ago

Any reason why composing the views works , and using view share does not ?

katifrantz left a reply on View Sharing , Laravel 5.3 • 7 months ago

Thanks mate, the view compose method of sharing data worked . ;)

21st December, 2016

katifrantz left a reply on What Is The Best Way To Integrate Rest Api? • 7 months ago

are you using vuejs ? It's easier with that. If not, then just loop over the data , and append a new table row to the dom using plain javascript , or jquery .

katifrantz left a reply on View Sharing , Laravel 5.3 • 7 months ago

This facade is already registered in my app.php .


'aliases' => [

    'View' => Illuminate\Support\Facades\View::class,

]

If the view class was the problem, then the exception thrown would have been different. :( . Any other ideas bro ?

katifrantz left a reply on View Sharing , Laravel 5.3 • 7 months ago

Yes, I did login myself. If I was not logged in, I would automatically be redirected to /login route by the Auth middleware . But me viewing the app.blade.php means I am authenticated.

katifrantz started a new conversation View Sharing , Laravel 5.3 • 7 months ago


<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use View;

use Auth;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

            if(Auth::check())
            {
                view()->share('nots', Auth::user()->notifications);
            }
    }
    
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}


```bash


Undefined variable: nots (View: D:\laragon\www\te\resources\views\app\layouts\app.blade.php) (View: D:\laragon\www\te\resources\views\app\layouts\app.blade.php)



What the hell am i doing wrong ??? Thanks 4 your help .

15th December, 2016

katifrantz left a reply on Social Network In Laravel 5.3 And Vuejs 2.0 • 8 months ago

Just did ;). Thanks

katifrantz started a new conversation Social Network In Laravel 5.3 And Vuejs 2.0 • 8 months ago

It's happening here ! ;) Thought I should share

10th December, 2016

katifrantz started a new conversation REPL.IT API CLONE IN LARAVEL AND UBUNTU 16 • 8 months ago

Hey guys, checkout this website. https://repl.it/site/api . Can I build such an api with laravel ? I actually think I can, but what I really wanna understand is how they setup a server to receive and execute all those API requests ? How might they have taken care of security , scaling, execution of code, in all those languages , etc . Please any little you know about this could be really helpful.

30th November, 2016

katifrantz started a new conversation KEEPING USER'S PERSONAL STUDY TRACK • 8 months ago

Hey guys, how does laracasts keep track of percentage completed on courses, and the uncompleted and completed courses for each user ? Any ideas ?

15th November, 2016

katifrantz left a reply on Php Artisan Make:component (Make Vue Component) • 9 months ago

Hey @balistikbill , you can use a vue component in both ways . For example , in my current project , I have a component just for the user profile, which obviously I would use only once, on the user_profile page . I factored this into a component because I needed vue's reactivity system . On the component, there is a follow button, just like twitter . When this button is clicked, I wanna increase number of followers by 1 , and with vue, this is seamlessly easy since all of this is one whole component . Also, when the unfollow button is clicked , I also reduce followers count by 1 . So this is a clear example where I spot it once into my code .

On the other hand, this component is still kinda dynamic , because on page load, it receives a prop, which is the id of the user whose profile we wanna use.. then it makes a quick database query and gets all the info from laravel behind the scenes .

I hope this helps you, you can create as many single components as u want, so far as they are useful to you. Hope I helped :-))

katifrantz started a new conversation Php Artisan Make:component • 9 months ago

Hey guys, I just engaged myself into a large laravel project, and I found myself creating close to 25 Vue components, which was a pain in the ass . So I got lazy and created a laravel package to do this for me. It might be totally useless if you are working on a project with very few vue components, but if the project becomes larger, and you love sticking to the laravel way of doing things, It might get useful . So Check it out . Pretty simple and dull though :-))

katifrantz left a reply on Laracasts Refresh • 9 months ago

@JeffreyWay I just saw some bug ... I tried to browse to the lessons area and some error popped up with Unexpected \provider or something .. i tried navigating back and then it was gone . Sorry I can't get you any more info about this ... But it should be somewhere around the lessons area :-)

katifrantz left a reply on Laracasts Refresh • 9 months ago

@JeffreyWay this is perfect design . Totally awesome !

14th November, 2016

katifrantz left a reply on Send Image With Ajax L5 • 9 months ago

@abeer , your code is poorly formatted . Please write better markdown. Can't c a thing

katifrantz left a reply on Middleware, A Group Admin Checker • 9 months ago

Just create your middleware , copy and paste your above logic into the handle method of your middleware , just before the return $next($request); line. (You can follow Laravel's out of the box middlewares as a guide) .Then , register your middleware in the App\Http\Kernel.php file . The docs should help you out . :-)

katifrantz left a reply on Twitter-following Packages For Laravel 5 • 9 months ago

@martinbean, Thanks for your reply . I already implemented it , created a trait and had the User class use it . i just wanted to find out if there were any packages out there . For anyone who's googling , here's my code . Will push it up to my github later .

1 - Migration file create_follows_table


<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFollowsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('follows', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('user_id');
            $table->integer('user_being_followed_id');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('follows');
    }
}


2 - Model file Follow.php


<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Follow extends Model
{   
    /**
     * relationship with the follower
     * @return [type] [description]
     */
    public function user()
    {
        return $this->belongsTo('App\User');
    }


    protected $fillable = ['user_id','user_being_followed_id']; 
}


3 - The trait FollowingTrait.php


<?php

namespace App\Traits;

use App\Follow;

use Auth;
/**
* A trait consumed by the User class
*/
trait FollowingTrait {


    /**
     * follow a user 
     * @param  [type] $id [id of user being followed]
     * @return [type]     [follow instance]
     */
    public function follow($id)
    {
        $follow = Follow::create([
            'user_id' => Auth::id(),
            'user_being_followed_id' => $id
        ]);
        return true;
    }

    /**
     * unfollow a user
     * @param  [type] $id id of the user being unfollowed
     * @return [type]     [description]
     */
    public function unfollow($id)
    {
        $follow = Follow::where('user_being_followed_id', $id)
                                ->where('user_id', $this->id)
                                ->first();
        $follow->delete();
        return true;
    }   

    /**
     * get all the users following this user
     * @return [type] [description]
     */
    public function all_followers()
    {
        $follow_instances =  Follow::where('user_being_followed_id', $this->id)
                        ->get();
        $followers = [];

        foreach($follow_instances as $follow)
        {
            array_push($followers, $follow->user);
        }
        return $followers;
    }

    /**
     * get all the users this->user is following
     * @return [type] [description]
     */
    public function all_following()
    {
        $follow_instances =  Follow::where('user_id', $this->id)
                    ->get();
        $following = array();

        foreach($follow_instances as $follow)
        {
            array_push($following, $follow->user);
        }
        return $following;
    }

    /**
     * return all followers id's
     * @return [type] [description]
     */
    public function all_followers_ids()
    {
        $follow_instances =  Follow::where('user_being_followed_id', $this->id)
                        ->get();
        $followers_ids = [];

        foreach($follow_instances as $follow)
        {
            array_push($followers_ids, $follow->user()->pluck('id')->all()[0]);
        }
        return $followers_ids;

    }

    /**
     * get all the ids of all the users this->user is following
     * @return [type] [description]
     */
    public function all_following_ids()
    {
        $follow_instances =  Follow::where('user_id', $this->id)
                    ->get();
        $following = array();

        foreach($follow_instances as $follow)
        {
            array_push($following, 
                $this->where('id', $follow->user_being_followed_id)
                                      ->pluck('id')
                                      ->all()[0]);
        }
        return $following;
    }

    /**
     * check if $this->user is following the user with id , id
     * @param  [type]  $id [id of user who might be following $this->user]
     * @return boolean     [true or false]
     */
    public function is_following($id)
    {
        if(in_array($id, $this->all_following_ids()))
        {
            return true;
        }
        return false;
    }

    /**
     * check if this->user is followed by user with id id 
     * @param  [type]  $id [description]
     * @return boolean     [description]
     */
    public function is_followed_by($id)
    {
        if(in_array($id, $this->all_followers_ids()))
        {
            return true;
        }
        return false;
    }

    /**
     * return number of users following this->user
     * @return [type] [description]
     */
    public function all_followers_count()
    {
        return count($this->all_followers_ids());
    }
    /**
     * return number of users this->user is following
     * @return [type] [description]
     */
    public function all_following_count()
    {
        return count($this->all_following_ids());
    }
    
}

4 - Controller FollowingController


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Follow;

use Auth;

use App\User;

use App\Http\Requests;

class FollowingController extends Controller
{
    /**
     * follow a user
     * @param  [type] $id id of user being followed
     * @return bool 
     */
    public function follow($id)
    {
        Auth::user()->follow($id);

        User::find($id)->notify(new \App\Notifications\NewFollower(Auth::user()));

        return response()
                ->json(true, 200);
    }

    /**
     * unfollow the user with id id
     * @param  [type] $id [description]
     * @return [bool]
     */
    public function unfollow($id)
    {
        return response()
                ->json(Auth::user()->unfollow($id),200);
    }

    /**
     * [checkIfAuthUserIsFollowingThisUser description]
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public function checkIfAuthUserIsFollowingThisUser($id)
    {
        if(Auth::user()->is_following($id))
        {
            return response()
                    ->json(true, 200);
        }
        return response()
                    ->json(false, 200);
    }
}


I'm consuming my controller with vuejs.

Hope it eases someone's work :-)

katifrantz left a reply on Laravel Migration Problem • 9 months ago

@manojvarma, Yea there isn't , that's why i asked if u got another migration . The error might be coming from somewhere else .

katifrantz left a reply on Laravel Migration Problem • 9 months ago

Is that the only migration you have ? Coz this error means you are doing something like this :

$table->number('...');

katifrantz left a reply on How To Highlight Current Page Item? • 9 months ago

I'm working on a project right now, and the way I am doing it is :

1 - Passing a variable to each view called $title . 2 - In the main layout, where my navigation exists, for each of the nav items , i check if the current page is equal to the title variable i passed. If yes, i echo a simple active class already defined by css . If no, well i echo nothing . It kinda looks like this .

    <li class="<?php if($title == 'dashboard'){ echo 'active'; }else{ echo ''; } ?>">
        <a href="/admin/dashboard">
          <div class="icon">
            <i class="fa fa-tasks" aria-hidden="true"></i>
          </div>
          <div class="title">Dashboard</div>
        </a>
      </li>

And in my controller :


public function index()
{
    return view('dashboard')->with('title', 'dashboard');
}

katifrantz started a new conversation Twitter-following Packages For Laravel 5 • 9 months ago

Hey guys, know any packages for implementing twitter-like following in laravel 5 ? Thanks 4 your feedback :-)

13th November, 2016

katifrantz left a reply on Where Is Static Auth::User Method Code Goes Into • 9 months ago

into your User.php file, and it's not static .

12th November, 2016

katifrantz left a reply on Creating Beautiful Vector Images • 9 months ago

@schmidtke182 Yea , it does help a lot . Thanks man ! I'm just gonna keep this open for a while, in case there are other ideas. : -)

katifrantz started a new conversation Creating Beautiful Vector Images • 9 months ago

Hey guys , I just wanna find out something . Wanna start a blog, and I really wanna know how pretty vector images are made, for example, these ones in the laravel-news blog , and others .

https://laravel-news.com/2016/11/slack-bot/

https://laravel-news.com/2016/10/login-validation/

https://laravel-news.com/2016/10/laravel-blade-svg-directive/

https://laravel-news.com/2016/11/higher-order-messaging/

katifrantz left a reply on Pass Variable From Route To Controller • 9 months ago

This is because you are not passing the parameter from the view . The route is expecting a parameter to be passed from the view , as such :


{!! Form::open(['route' => ['forums.store', 'myTheory_id'], 'class' => 'form']) !!}

11th November, 2016

katifrantz left a reply on Is Vue 2.0 Much Different Than 1? • 9 months ago

lol . Not beg . He created this site, he's smart enough to know we need one, and I am sure he is definitely working on it :)

katifrantz left a reply on How To Check If Laravel Returns An Error Message In JSON • 9 months ago

@Chimit, the second parameter for the json method is the status code of the response . Therefore what you actually are sending is a 200, which is status code for success. Therefore to send an error message, you should use HTTP error status code , depending on the situation , either 401, 403, 500 , 404 etc depending on your error . Hope that helps .

katifrantz left a reply on Is Vue 2.0 Much Different Than 1? • 9 months ago

Not really, It would need a total upgrade . Most of the concepts have changed . If you wanna just understand how vue works , then its definitely worth the shot . It would help you get into vuejs2 , but you can't actually build anything , because you would have to know everything that has changed . So you either follow the tutorial , and read the upgrade guide, or you just wait for vuejs-2 tutorial, learn somewhere else. Good luck.

10th November, 2016

katifrantz left a reply on Laravel 5.2 Does Eloquent Model Create Return False? • 9 months ago

It returns nothing if it fails . Check out this method here . Illuminate\Database\Eloquent\Model.php.

katifrantz left a reply on Watch For External Database Changes Laravel 5 • 9 months ago

Are you broadcasting events to the client side ? If yes, then won't you just listen to this channel with your javascript ?

Edit Your Profile
Update

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