FutureWeb

Experience

24,825

0 Best Reply Awards

  • Member Since 4 Years Ago
  • 241 Lessons Completed
  • 0 Favorites

17th May, 2018

FutureWeb started a new conversation Load A Class With Every View • 2 months ago

is there anyway to load a class every time a page is rendered?

I simply want to parse the uri and then load all the bumf (meta, og tag any dependent js etc) each time a page has loaded the reason being I want to store it all in db tables to make it manageable by a web admin user.

11th May, 2018

FutureWeb started a new conversation Insert All Data From Temp Table Without Looping • 2 months ago

Hiya LaraPeeps,

I have a number of temp tables which huge amounts of data are imported into using some custom artisan commands.

these run as jobs a couple of times a day I want to copy everything from the temp to live tables as quickly as possible with as little load as possible, one table contains up to 6.5 million records.

temp and live tables are identical.

I am after something like an insert using a sub select:

INSERT INTO live_table (SELECT * FROM tmp_table)

Any help or advice would be greatly appreciated.

19th April, 2018

FutureWeb left a reply on Trigger An Artisan Command When Endpoint Is Hit Then Another When That Is Complete • 3 months ago

Do you know what I didn't even think of that LOL what about the parsing just stick it in a job que?

FutureWeb started a new conversation Trigger An Artisan Command When Endpoint Is Hit Then Another When That Is Complete • 3 months ago

Hiya LaraFolks,

I am looking to trigger an artisan command when an end point is hit and then another when that command is complete.

here's the plan..

1). I fire a command using a cron twice a day at specific time this generates some data on another server and saves the output to a file. -> This I have done.

2). The server responds once complete to an end point on my server I provide a unique single use token in my call back and check the ip of the responding server. -> This is done also

3). When this end point is hit and validation is passed I want to trigger another artisan command to download the data.

4). Then once the data has downloaded I want to trigger another command which parses it.

I have written and tested all the commands I just need to figure out how to trigger 3 and 4 any help would be very much appreciated.

3rd February, 2018

FutureWeb left a reply on Anyone Know How To Embed An Image In A Laravel Markdown Email? • 5 months ago

lol sorry yes you are correct I got it working with the above with brackets I couldn't get the full url to work or embed for some reason and it seems pretty quirky with indentation in markdown. But all that said your answer is correct but for anyone else use asset($path_to_file)

FutureWeb left a reply on Anyone Know How To Embed An Image In A Laravel Markdown Email? • 5 months ago

the only way i could do it was ![alt]{{asset('image_path')}}

FutureWeb started a new conversation Anyone Know How To Embed An Image In A Laravel Markdown Email? • 5 months ago

Hiya larpeeps,

Does anyone know how to embed an image in a laravel Markdown email?

21st January, 2018

FutureWeb left a reply on GroupBy Works On Local Testing Server But Not On Production? • 6 months ago

Perfect thank you

FutureWeb left a reply on GroupBy Works On Local Testing Server But Not On Production? • 6 months ago

Also if I dump the query into phpmyadmin on the production server it works fine?

FutureWeb started a new conversation GroupBy Works On Local Testing Server But Not On Production? • 6 months ago

Hi LaraPeeps,

I have this relationship in my User Model: public function invoices() { return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoices.id','orders.user_id']); }

this works as does the below (on my local machine)

    public function invoices()
{
    return $this->hasManyThrough('App\Invoice','App\Order','user_id','id','id','invoice_id')->groupBy(['invoice_id','user_id']);
}

but on my production server I get this error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'shopsite_db.invoices.title' isn't in GROUP BY (SQL: select `invoices`.*, `orders`.`user_id` from `invoices` inner join `orders` on `orders`.`invoice_id` = `invoices`.`id` where `orders`.`user_id` = 1 group by `invoices`.`id`, `orders`.`user_id`)

18th January, 2018

FutureWeb left a reply on Best Approach To Group Orders To Each Invoice • 6 months ago

Hi thanks for the response Invoice has no user_id, user_id can only be found through the orders table

17th January, 2018

FutureWeb started a new conversation Best Approach To Group Orders To Each Invoice • 6 months ago

Hi Lara Folks,

I have two tables:

orders:
id, product_id, user_id, price

invoices:
id, order_id, total, payment_status

I want to list all orders per user but group them by invoice so:

user1 orders product 1,2,3 and 4 pays invoice number 1 and then orders product 5,6,7 and 8 and pays invoice 2

I would like to display this as:

Invoice 1: Product xx - £20 Product xxx - £10

Invoice 2: Product yy - £30

you get the idea the long and the short of it is I need to access the invoices through the orders table but group by invoice

is there a nice simple way using Eloquent relationships rather than writing a join

11th January, 2018

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

@GertjanRoke Yep its an out of the box auth:make

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

   $data = \Session::get('_previous');
    $url = $data['url'];
    dd($url);

seems to be what I need

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

here are the routes that redirect to the login a form is posted to /play then that stores the data in a session and redirects to checkout which checks auth if it fails it redirects to login and then after login it should redirect back to checkout

Route::get('/checkout', function(){

 if(!auth::check())
 {
     return redirect('login');

 }

  $post = Session::get('cart');
  $post = $post[0];
  $post['user_id'] = auth::user()->id;

   return view('checkout', compact('post'));

});

Route::post("/play", function(){ $post = $_POST; if(Session::has('cart')) { Session::forget('cart'); }

    Session::push('cart', $post);

    return redirect('checkout');
 });

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

im getting this now: (after login)

Header may not contain more than a single header, new line detected

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

Still no joy :( I just get a blank screen not even a stack trace

FutureWeb left a reply on Redirecting Back To Intended Laravel 5.5 • 6 months ago

Sorry i wasn't very clear when the user hits a page that requires auth I redirect them to the login form after they have successfully logged in I want to redirect them back to the page they intended to view.

FutureWeb started a new conversation Redirecting Back To Intended Laravel 5.5 • 6 months ago

I am trying to redirect the user to intended after login so I have taken out the $redirectTo property from the LoginController which is generated by artisan make:auth and added this method:

''' protected function redirectTo(){

    return redirect()->intended('/home');
}

'''

But it only ever redirects home ? any help would be great.

10th January, 2018

FutureWeb left a reply on Force Https Laravel 5.5 • 6 months ago

Yep could do just feels quick and dirty :(

FutureWeb started a new conversation Force Https Laravel 5.5 • 6 months ago

Since upgrading to 5.5 my force https seems to have stopped working I have changed schema to shceme this is in my app/AppServiceProvider class under the boot method it worked in previous versions any ideas?

5th January, 2018

FutureWeb left a reply on Using Recursion And Getting Json Keys Which Double As Array Names • 6 months ago

Brilliant thanks I passed in a counter variable to keep track of the depth in the end.

3rd January, 2018

FutureWeb left a reply on Using Recursion And Getting Json Keys Which Double As Array Names • 6 months ago

cant do the code block either lol

FutureWeb left a reply on Using Recursion And Getting Json Keys Which Double As Array Names • 6 months ago

Ok I have written a recursive function to handle this but now my problem is I cannot keep track of the depth any ideas?

'''' public function anything($json){ $array = json_decode($json, true);

return $this->recursive_key_val_lookup($array);

}

private function recursive_key_val_lookup($array=[]) {

   foreach($array as $key=>$val)
   {
       if(is_array($val))
       {
           echo "$key is array<br>";
           $this->recursive_key_val_lookup($val);
       } else {
           echo "$key => $val";
       }
   }
}

'''''

FutureWeb started a new conversation Using Recursion And Getting Json Keys Which Double As Array Names • 6 months ago

I have the below json to parse, this can go to any depth it contains an array called groups and within groups are sub groups which contain an id and a description the description doubles as an array name for a sub sub group which again contains an id and a description which in the instance below then contains and array of items id, groupingId, title, desc.

What I am trying to do is extract the id and description of the first 2 levels so group.id=2 group.description=Inclusive Services and sub_group.parent_id=2 sub_group.id=255-3 sub_group.description=Service Attributes and so on.

the problem I have found is I cannot seem to get the description of the group or sub group as it is an array.

{
  "groups": [
    {
      "id": "2",
      "Inclusive Services": [
        {
          "id": "255-3",
          "Service Attributes": [
            {
              "id": "13",
              "groupingId": "M3",
              "title": "BlackBerry Services",
              "desc": "Use the internet, email and BBM on your BlackBerry to share messages, pictures and more for free. Sync with your PC or Mac and take your favourite music, photos and videos wherever you go."
            }
          ]
        },
        {
          "id": "255-5",
          "Enhanced customer service": [
            {
              "id": "79",
              "groupingId": "M5",
              "title": "O2 Pay and Go Rewards",
              "desc": "As a new customer, when you join O2 Pay & Go and opt into O2 Rewards, you''ll earn 5% back on all top-ups every three months. So, if you top up £50, you can get £2.50 back at the end of the quarter. Even better, after you''ve been with us for six months, the % of rewards you earn will increase to 10%."
            }
          ]
        },
        {
          "id": "255-11",
          "Roaming services": [
            {
              "id": "73",
              "groupingId": "M11",
              "title": "O2 Travel",
              "suffix": "For the length of your contract",
              "desc": "O2 Travel is your perfect holiday companion.You can download TripAdvisor City Guides for reviews on things to do, the best places to eat and maps you can use offline. And if you are missing home, you can talk for up to an hour for a connection charge of just 50p and access all the data you need for just £1.99 per day."
            }
          ]
        },
        {
          "id": "255-4",
          "Entertainment freebies and discounts": [
            {
              "id": "64",
              "groupingId": "M4",
              "title": "O2 Priority",
              "suffix": "For the length of your contract",
              "desc": "Priority from O2 gives you access to exclusive offers and events including lunch for £1 every Monday. Grab some VIP treatment for you and your friends with access to gig tickets up to 48 hours before general release, exclusive entry to O2 bars and side step the queues with fast track lanes at O2 venues."
            },
            {
              "id": "65",
              "groupingId": "M4",
              "title": "O2 Tracks",
              "suffix": "For the length of your contract",
              "desc": "O2 Tracks gives you nonstop access to all the hottest music videos, top 40 playlists and backstage gossip. Try it for free with a four week free trial when you join O2 – no ads, no streaming, just great music."
            }
          ]
        },
        {
          "id": "255-23",
          "Free or discounted allowances": [
            {
              "id": "68",
              "groupingId": "M23",
              "title": "O2 TU Go",
              "desc": "TU Go is a free app that lets you use your O2 number on smartphones, tablets and laptops.It''s just like using your phone. Sign in to TU Go using a wifi connection to get your calls, texts and voicemail on up to 10 devices. The person you''re talking to doesn''t even need to have the app.Our latest version of TU Go now also lets you use the app over any mobile data (3G / 4G) connection – so you can now use TU Go for calls, texts and voicemails whenever you have mobile data available. If you want to use mobile data for TU Go calls, you can switch this on in Settings."
            },
            {
              "id": "69",
              "groupingId": "M23",
              "title": "O2 WiFi Hotspots",
              "desc": "Stay connected with O2 WiFi Hotspots available in thousands of locations nationwide including All Bar One, Debenhams, Café Rouge, Costa, House of Fraser, McDonalds and Subway."
            }
          ]
        },
        {
          "id": "255-25",
          "Free or discounted software": [
            {
              "id": "80",
              "groupingId": "M25",
              "title": "Evernote Premium for a year",
              "desc": "Experience Evernote Premium free for 1 year. With Evernote Premium you can capture your ideas, tasks, projects and more. You can share and edit your notes, access your work anywhere offline and get 1GB of free uploads each month."
            }
          ]
        }
      ]
    },
    {
      "id": "4",
      "Comes with (chargeable)": [
        {
          "id": "255-2",
          "Pay as you go Top-up": [
            {
              "id": "5",
              "groupingId": "M2",
              "title": "Pay as you go Top-up: £20",
              "suffix": "Topup",
              "cost_type": "Fixed",
              "cost": "20.00",
              "desc": "This product comes with a mandatory top-up charged at £20, meaning you will have £20 credit to use (or on your account)."
            }
          ]
        }
      ]
    }
  ]
}

26th July, 2017

FutureWeb left a reply on Oembed Package For Laravel 5.1 • 11 months ago

Any for L5.4? I can't seem to find one

24th November, 2016

FutureWeb left a reply on Add Integer To Eloquent Collection • 1 year ago

Solved

FutureWeb left a reply on Add Integer To Eloquent Collection • 1 year ago

Yes of course :) thanks should have been $count->aggregate; what a mistakea to makea

FutureWeb started a new conversation Add Integer To Eloquent Collection • 1 year ago

Hi LaraPeeps,

I am trying to add an integer to an eloquent collection:

$deals = Deal::with('stuff')->where('this','=','that')->take(20)->get();

and then I am trying to append an integer to the collection like this

$deals->last_page = $count;

or like this

$deals->put('last_page',$count);

but I always get the following error: Object of class stdClass could not be converted to int

Any pointers would save me a good amount of hair.

Thanks in advance :)

7th August, 2016

FutureWeb started a new conversation Before Send / Before Route(s) Fire • 1 year ago

Can I do if(Auth::check()) { if(!Auth::user()->email) { return redirect('/dashboard')->with('error', 'You have not provided an email address')' } }

reason being I have a social login and twitter logins do not provide an email address nor do some facebook logins for some reason, if you can think of a better option then redirecting the user to the dashboard and a add email form please share it as on registration I send out a welcome email via an event handler and listener and it would save me putting the same logic in the controller before firing the event if that makes sense?

thanks in advance larapeeps.

21st July, 2016

FutureWeb left a reply on Send Welcome Email On User Registration • 2 years ago

seemed to be a server config issue with me server being set only allow outgoing emails to root account, and now it looks like my ip is blacklisted :( which is odd as I have never sent mail out using it before, so that's it I am using mailgun

FutureWeb left a reply on Send Welcome Email On User Registration • 2 years ago

yes I do I would have thought an exception would be thrown but I get nothing

FutureWeb started a new conversation Send Welcome Email On User Registration • 2 years ago

I am trying to send a welcome email when a user registers Laravel 5.2, I have the following code in my Auth controllers user create method:

        $user = User::findOrFail($id);
        Mail::send('emails.welcome', $user, function($message) use ($user)
        {
            $message->from('[email protected]', 'xxxx.uk');
            $message->subject("Welcome to xxxxx.me.uk");
            $message->to($user->email);
        });

just before the return but it does not fire I get no errors or exceptions but I get no mail either its driving me up the wall!

20th July, 2016

FutureWeb left a reply on Sending A Welcome Email • 2 years ago

I am trying to achieve the same thing did you ever find how to do it?

7th December, 2015

FutureWeb left a reply on Paypal IPN Laravel 5.1 - 405 Not Allowed?? • 2 years ago

Hahahaha what a mistakea-to-makea!! I have it as get not post!!

FutureWeb started a new conversation Paypal IPN Laravel 5.1 - 405 Not Allowed?? • 2 years ago

Hi LaraPeeps,

I am trying to use the paypal Ipn to log donations - I have disables csrf for the route using:

protected $except = [
    'payments/paypal'
];

in app/http/middleware/verifycsrftoken

but I still get a 405 from the paypal sandbox ipn testing tool :(

I have tried ready made curl, fsocket and even the fahim laravel package but cannot get a thing to work!! its driving me insane.

6th December, 2015

FutureWeb left a reply on Hook Into Successful User Registration Laravel 5.1 • 2 years ago

i get: Cannot make static method Illuminate\Database\Eloquent\Model::boot() non static in class App\User

FutureWeb started a new conversation Hook Into Successful User Registration Laravel 5.1 • 2 years ago

Hi LaraPeeps,

How do I hook into a successful user registration in 5.1

Can I just do if(User::create([..])){ ..// further db insert }else{ // throw exception }

Thanks in advance

26th October, 2015

FutureWeb left a reply on Controller Showing Up In Views Storage ? • 2 years ago

LOL me being stupid sorry - copied my controller to the view by mistake on the server :)

FutureWeb started a new conversation Controller Showing Up In Views Storage ? • 2 years ago

I have an odd problem I am getting a fatal exception Cannot redeclare class App..\HomeController but its in ../storage/framework/views/xxxxxx. when I open the view from the storage dir its an exact copy of my HomeController ? I am using laravel 5.1 any ideas folks?

18th October, 2015

FutureWeb started a new conversation Cached Ajax Pagination With Orderby And Where • 2 years ago

is it possible to manipulate a cached paginated collection with relationships?

for instance: if(isset($_GET['page']) { $page=$_GET['page']; } else{ $page = 0; } $product = Cache::remember('product'.$page,7200,function() use($brand){ return Product::with('specs','prices','retailers') ->where('brand','=',$brand) ->orderBy('popularity','desc') ->paginate(20); });

   if($page>0 || isset($_GET['order']))
   {
       // its an ajax request.. 
        if($_GET['order'] == 'price')
         {
                // order by price on prices with relationship
         }
         elseif($_GET['order'] == 'screensize')
         {
                // order by screensize on specs with relationship
        } // etc..

11th October, 2015

FutureWeb started a new conversation Unique Value From Column On Existing Collection • 2 years ago

if I pull a paginated collection with many rows and columns can I pull a single column with only unique values in to a new object or array?

Thanks in advance

FutureWeb left a reply on Concat? Is There An Option For This? • 2 years ago

Perfecto thanks :)

FutureWeb started a new conversation Concat? Is There An Option For This? • 2 years ago

lets say I want to search by first and last name together or just first name

    where(CONCAT_WS(' ', 'first_name', 'last_name') LIKE '%'.$query.'%')
            ->orWhere('first_name','LIKE','%'.$query.'%');

I am sure there must be a simple way to do this and I am just being thick :)

Thanks in advance

28th August, 2015

FutureWeb started a new conversation Handling Massive Record Sets • 2 years ago

Hi LaraPeeps,

I have a class that imports large amounts of data this use to be done by importing directly from the csv feeds and calling functions to sort and separate the data into different db tables.

I am now trying to move this to dumping the entire feed into a raw_datas table then loop through the records and insert into the various tables I need. So far the load data in file works great and my functions to insert the data also works well except when I try to work with lots of records it seems to handle 5k ok but the raw_datas table holds up to 1.7 million rows at a time depending on what deal type I am importing.

The whole thing needs to run as a cron job daily so I need a way of importing all the data in chunks to stop it falling over. I know the server is capable of importing all the records in one hit as I my old vanilla php import code works fine.

the process works by the script calling a service which generates the datafeed and then in turn hits a url on my server telling it the feed is ready for download next my script fetches the feed saves it to the server and unzips it and then dumps it in to the raw_datas table.

there are 4 csv's generated and absorbed in this way and they range in size from 385k - 1.2gb

can this be done under laravel or should I sack it and go back to old school php for the import? if it can any ideas on splitting the import down into chunks? I know I can paginate the results is there a way I can get the function to call it's self when it reaches the last ?

Thanks in advance

26th August, 2015

FutureWeb started a new conversation Load Data In File • 2 years ago

can we do load data infile with laravel? I found this but it's not working:

     private function loadData($file)
     {

        $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE raw_data FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES", addslashes($file));

        return DB::connection()->getpdo()->exec($query);

    
    }

FutureWeb started a new conversation Min / Max On Model • 2 years ago

Hi all I am trying to get a min and max value on my model like this:

 public function monthly()
 {
      return $this->hasOne('App\PhoneDeals')
           ->selectRaw('min(monthly_cost) as monMonthly, max(monthly_cost) as maxMonthly')
           ->groupBy('monthly_cost');
 }

but this doesn't work any pointers on what I am doing wrong would be greatly appreciated.

24th August, 2015

FutureWeb left a reply on Foreach On With Toarray • 2 years ago

thanks all stay tuned for the next helping of spaghetti :)

FutureWeb left a reply on Foreach On With Toarray • 2 years ago

Changing the relationship from belongsTo to hasMany did the trick

Edit Your Profile
Update

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