sasafister

at Freelancer

Hire Me

Experience

24,345

4 Best Reply Awards

  • Member Since 4 Years Ago
  • 270 Lessons Completed
  • 9 Favorites

15th May, 2018

sasafister started a new conversation Is It Smart To Have Dusk In Packages? • 1 week ago

I have a package and I want to write a test for it. Generally, I want that test covers only package because I will have multiple packages and I don't want for the test to fail because there is no package installed (I'm talking about root composer.json).

My question is.

  1. Is it ok to have vendor directory in packages (of course, I can put that folder into gitignore)
  2. Is it ok to have Dusk for every package?

20th March, 2018

sasafister left a reply on Email Template Doesn't Show Images On Gmail • 2 months ago

I use URL::asset, or you can use shorthand asset(), but I've put ../img/image.png, so all I had to do is remove "../" and it all works fine. On my local machine it doesn't show image, because of reason mention above.

19th March, 2018

sasafister left a reply on Email Template Doesn't Show Images On Gmail • 2 months ago

Everything works fine now on production. Thnx guys

sasafister left a reply on Email Template Doesn't Show Images On Gmail • 2 months ago

I have this

APP_URL=http://elea.test

which works fine for Apple, but not on Gmail

sasafister left a reply on Email Template Doesn't Show Images On Gmail • 2 months ago

Thank @bobbybouwmann I will try this!

sasafister started a new conversation Email Template Doesn't Show Images On Gmail • 2 months ago

We have build subscription logic which contains email template for welcome email. When I view email on my local machine in Apple Mail, everything works fine, but when I open email on gmail (using website) then images are not showed up. I use URL::asset for fetching images from public/img folder.

Anyone has a clue how to solve this annoying issue?

13th November, 2017

sasafister started a new conversation Can't Dd() Data From Axios Post Request • 6 months ago

I have very simple app which is build on React. I'm using axios to send post request to Laravel. Everything is working fine until when I dump request with

$data = request()->input();

when nothing is getting dumped except this JS code. Anyone knows solution?

ja<script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/,

10th September, 2017

sasafister left a reply on Router Refresh With React In Mix • 8 months ago

bump

8th September, 2017

sasafister started a new conversation Router Refresh With React In Mix • 8 months ago

How can I fix issues with refresh. App was build on ReactJS and it works fine, but when I go to some route i.e. '/posts' and hit refresh, basically I'm hiting server request, and I want to stay on client side with that route. So what do I need is that after refreshing some route, to get React to respond on that route. Any ideas how can I do that?

5th July, 2017

sasafister started a new conversation How To Fix Url Server Refresh (React) • 10 months ago

Obvious, that's nothing new. I have app that uses reactjs for navigating through different pages. So I want to be able to return user back to 'reactjs route' after they hit refresh. Basically, if user is on /about page and hits refresh, I want to ping react to trigger that route.

I'm using react-router 4.

8th June, 2017

sasafister left a reply on How Do You Handle Routes When Using SPA? • 11 months ago

I will try @tykus solution and let you know guys. Thnx

sasafister left a reply on How Do You Handle Routes When Using SPA? • 11 months ago

I got it @tykus that means, every time user refresh url it will land on index view. But i know that exist another way of doing this, so if user refresh, let say, /posts/featured it will land on that url (javascript loading).

sasafister started a new conversation How Do You Handle Routes When Using SPA? • 11 months ago

I'm building ReactJS app with Laravel on the backend. Everything works fine, but problem is when you hit refresh after you navigate through your website. So for example, you end up on route like this

/posts/latest

This is the route that React fetches latest posts, but if I hit refresh, obvious, that route doesn't exist in Laravel routes, so it throws Exception, which is expected behavior. So how do you handle that? Do you redirect users on home page, or do you write sam JS code?

31st March, 2017

sasafister started a new conversation Fetching Data Without Browser? How? • 1 year ago

I've created web app that parses html code and saves it into db. Problem is that my web browser/page needs to be opened so javascript can trigger request every 2minutes (I'm using basic jQuery AJAX request). I need some way to avoid browser, so that standalone web app parses data by itself. How can I do that?

21st October, 2016

sasafister left a reply on Using GeoIp For Fetching Location • 1 year ago

@Nasir that was two years ago, I don' remember, but try to read documentation

6th July, 2016

sasafister left a reply on How To Add Name Of Developer In Each New File? • 1 year ago

@tomo_pongrac nope, win and mac

sasafister left a reply on How To Add Name Of Developer In Each New File? • 1 year ago

@tomo_pongrac but I need it for every file that has been created

@phpMick I use Atom for now, but guys are using different IDE's.

sasafister started a new conversation How To Add Name Of Developer In Each New File? • 1 year ago

We are working in teams, and need to document who is working on which files. So for example, I create new model and we should have in comment on top of file something like /* Created by: sasafister */

How can i do that automatically?

13th January, 2016

sasafister left a reply on [jQuery] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

I got it. Your code @arif was all I needed. I put

$('#numVote' + $id).html(data);

and i put

 <td id="numVote{{ $title->id }}" >{{ $title->votes }}</td>

sasafister left a reply on [jQuery] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

Not working @arif , so ID id fine, update is tricky part

sasafister left a reply on [jQuery] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

Okay. So, everything works fine, that means, success method is doing his job, and in database everthing is updated as supposed to be. Only thing is that I need to updated correct (clicked) row in table.

Try this one:

user: sasa@zimo.co pass: 123456

http://dev.ozim.info/zimo_schedule_test/

sasafister left a reply on [jQuery] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

Nope @arif still the same thing.

sasafister left a reply on [jQuery] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

@bobbybouwmann thnx for reply, acutally, I got dyamic ID, everything works fine, but when I update data in #numVote (ajax success) then everthing is updated (I changed #numVote into .numVote)

sasafister started a new conversation [jQurey] How To Update Id On Which I Clicked After AJAX Success? • 2 years ago

Everything works fine, except when I click "thums up" button, it always update my first row in table.

My code is on github, so you can see it there, and here is just excerpt

https://github.com/sasafister/scheduler/blob/materialdesign/resources/views/titles/index.blade.php

 var url = "{{ url("/") }}" + "/{{ Auth::user()->id }}" + "/titles"

    $("#upVote i").on("click", function() {
        $.ajax({
            type: 'POST',
            url: url + "/upvote" + "/" + this.id,
            success: function(data) {
                $('#numVote').html(data);
            }
        });
    });
```

@foreach ($titles as $title) @if($title->created_at > \Carbon\Carbon::today()) {{ \Carbon\Carbon::parse($title->time)->format('d.m.') }} {{--{{ $title->id}}--}} {{ $title->user->name }} {{ $title->title }} thumb_down {{ $title->votes }} thumb_up {!! link_to_action('TitlesController@show', 'Edit', [$customer, $title->id]) !!} @elseif($title->created_at < \Carbon\Carbon::today()) {{ \Carbon\Carbon::parse($title->time)->format('d.m.') }} {{ $title->user->name }} {{ $title->title }}

            @endif
        @endforeach

10th January, 2016

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

So yeah, I figure it out. Stupid me. I was POST-ing on wrong url. I haven't registered /upvote url, and I didn't use url() to grab relative URL, but was hardcoding it. Now it's working. I thought that was some silly mistake, but that's how developement works, right :)

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

Stil nothing, well that's weird.

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

I'm trying to upload everything once again, but I think that token works, I will try your suggestion @mrabbani thnx

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

hi @skliche i tried that but it won't work, I think that's something with nginx on server or something.

9th January, 2016

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

Actually @brti route is ok, if I click on the button, it takes me to the right url

equest URL:http://dev.ozim.info/upvote/69
Request Method:POST
Status Code:500 Internal Server Error

sasafister left a reply on Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

@renedekat I wrote it up, nothing in log files :(

sasafister started a new conversation Ajax Request 500 Error, Don't Even Hit The Route • 2 years ago

I'm working on my app and locally everything works perfectly, but when I push project on production server, AJAX request breaks down. I have put X-CRSF token, nothing is in my log file, routes are working fine, but still getting 500 error.

Here is my AJAX code

$.ajax({
            type: 'POST',
            url: '/upvote/' + this.id,
            success: function(data) {
                $('#numVote').html(data);
            }
        });

So, I can't reach my route, even tough they exist in routes

Route::post('/upvote/{id}/', function($id) {

   $title = \App\Title::find($id);
    $title->votes = $title->votes+1;

    $title->save();

    return $title->votes;
});

Does anyone has idea what should I try?

6th January, 2016

sasafister left a reply on Auth Works On My Local Env, But When I Push It On Production, It Won't Login • 2 years ago

I just put empty space in my action in form it worked

            {!! Form::open(['url' => ' ', 'method' => 'POST']) !!}

5th January, 2016

sasafister left a reply on Auth Works On My Local Env, But When I Push It On Production, It Won't Login • 2 years ago

I get apsolutly nothing @ejdelmonico

I can't event hit the post route

Route::post('/', function(){

    return "something";
    
});

Chrome send back:

Request URL:http://dev.ozim.info/zimo_schedule_test
Request Method:POST
Status Code:301 Moved Permanently
Remote Address:185.58.73.38:80

then it goes to get (/) route which is fine, is this problem with trailing slashes?

sasafister left a reply on Auth Works On My Local Env, But When I Push It On Production, It Won't Login • 2 years ago

Yes @ChristopherRaymond for now, I'am just testing the web. So the route is

public_html/ozim.info/dev/zimo_schedule_test/

and I put entire Laravel project inside this folder

sasafister started a new conversation Auth Works On My Local Env, But When I Push It On Production, It Want Login • 2 years ago

Here is my project (this is test web)

http://dev.ozim.info/zimo_schedule_test/public/

the problem is, everything works fine on local but I can't login on production. When I want to login it redirects me back on login page. I searched about trailing slashes, but I don't think that's the problem here. Chrome gives me reponse of

Request URL:http://dev.ozim.info/zimo_schedule_test/public
Request Method:GET
Status Code:301 Moved Permanently
Remote Address:185.58.73.38:80

I tried put action with controller name in form, and rename routes so the post route for login have a different name, but this also won't work. I don't know what to do.

4th January, 2016

sasafister left a reply on Getting One Record From Array • 2 years ago

Think I figure it out. It's not prettiest thing in the world, but it get's job done. Here is what I come up with

$user->where('customer_id', Auth::user()->id)->get()[($request->author)-1]->id;

sasafister left a reply on Getting One Record From Array • 2 years ago

Thnx @JeffreyWay for help, but I what I post above is returned from

$user->where('customer_id', Auth::user()->id)->get()

so I need to somehow fetch id in the get method

sasafister started a new conversation Getting One Record From Array • 2 years ago

My POST request returns this data

Collection {#177 ▼
  #items: array:2 [▼
    0 => User {#181 ▶}
    1 => User {#182 ▼
      #table: "users"
      #fillable: array:3 [▶]
      #hidden: array:2 [▶]
      #connection: null
      #primaryKey: "id"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:6 [▼
        "id" => 9
        "name" => "Nikola Jozić"
        "customer_id" => 3
        "remember_token" => null
        "created_at" => "2016-01-05 00:40:44"
        "updated_at" => "2016-01-05 00:40:44"
      ]
      #original: array:6 [▶]
      #relations: []
      #visible: []
      #appends: []
      #guarded: array:1 [▶]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      #morphClass: null
      +exists: true
      +wasRecentlyCreated: false
    }
  ]
}

what I need is return only id from second array. How can I do that with Eloquent?

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@Snapey something like that?

public function render($request, Exception $e)
    {
        if ($e instanceof ModelNotFoundException) {
            $e = new NotFoundHttpException($e->getMessage(), $e);
        }
        if ($e instanceof PermissionDenied) {
//            flash()->danger('Authentication Error');
            return redirect('/');
        }

        return parent::render($request, $e);
    }

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@premsaurav thnx for helping me. Acutally, I get correct path if I dd what return in this method

 protected function isAuthenticUser($customer)
    {
        if ($customer->id != Auth::user()->id)
        {
            dd(route("admin", Auth::user()->id));
            return redirect()->route("admin", Auth::user()->id);
        }
    }

which is this route : "http://homestead.app/1"

but problem is with redirecting. I tried your method but it won't work either.

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@etkimbia nope, it won't work, problem is that it's working if i put everything into controller, but when I extract it to private method, then it won't return redirect, if that makes any sense.

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

I tried @etkimbia but it isn't working, here are my routes.

Route::get('/{id}/', ['as' => 'admin', 'uses' => 'CustomersController@index']);
Route::post('/{id}/', ['as' => 'admin', 'uses' => 'CustomersController@store']);

@Hulu I already have middleware setup for Admins, so I have Admin (main user who can add new "subusers"), and users

3rd January, 2016

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@etkimbia so, if I visit route /1 that works, and that's fine because the Auth::user()->id is equal to $customer->id (which is like admin user of app), and if i try to visit /2 when user 1 is logged in, it let me see that route, but that should not work. This line of code works fine, but I want to refactor it:

 public function create($id)
    {
        $customer = Customer::findOrFail($id);


        if ($customer->id != Auth::user()->id)
        {
            return redirect()->route("admin", Auth::user()->id);
        }

        return view('admin.create', compact('customer'));
    }

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@etkimbia

I'm trying to return redirect but it won't work, any ideas why? If I dd(); in there, everything seems ok, but it just won't redirect to route, even with return

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@etkimbia thnx for info, I'm trying to write as less as possible code because I need this for every method in class, any idea about that? How would you implement middleware here?

sasafister left a reply on Private Method Dosen't Return Valid Information? • 2 years ago

@etkimbia I don't need middleware here, I need to compare Authenticated user with user->id, that works fine, I just can't figure out why it want return me given route.

sasafister started a new conversation Private Method Dosen't Return Valid Information? • 2 years ago

Hi guys,

I'm working on an app, and I stucket at simple PHP method. So what I have is method in my controller

 public function index($id)
    {
        $customer = Customer::findOrFail($id);

        $this->isAuthenticUser($customer);

        return view('admin.index', compact('customer'));
    }

and I have private method

 private function isAuthenticUser($customer)
    {
        if ($customer->id != Auth::user()->id)
        {
            redirect()->route("admin", Auth::user()->id);
            
        }
        return true;
    }

the problem is that if the user is not Auth::user() it won't redirect me to the route. Problem is obvious very basic, but I just can't figure it out. Any help is appreciated.

16th December, 2015

sasafister left a reply on Authentication Not With User Class • 2 years ago

Figure it out. Problem was "unique:users".

  protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:customers',
            'password' => 'required|confirmed|min:6',
        ]);
    }

sasafister started a new conversation Authentication Not With User Class • 2 years ago

Hi guys, I'm working on app that have Customers and Users. Customers are global users, someone who signup on app, and users, are people who can add and edit data in app, someone who can Customer add as "manager".

So I can't figure out where Laravel 5.1 use Users as standard. I want to change it so i can store data in Customers, and not User class.

Edit Your Profile
Update

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