• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by SamC

  1. SamC

    This is a really nice font! Thanks for this
  2. SamC

    Still not sure whether 'dev talk' means talk about just PW or anything else?! Anyway, been working with Laravel for a bit now but still a bit confused about a certain thing. For example: namespace App\Http\Controllers; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { /** * Save new project */ public function store() { $project = new Project(); // <<<<<< NEW OBJECT $project->title = request('title'); $project->description = request('description'); $project->save(); // A GET request by default return redirect('/projects'); } } ... but I've since found out that you don't need to instantiate a new object in a method, you can type hint like so: /** * Update existing project */ public function update(Project $project) { // Update and save $project->title = request('title'); // <<<<<< OBJECT IS AVAILABLE LIKE MAGIC $project->description = request('description'); $project->save(); // A GET request by default return redirect('/projects/' . $project->id); } What I'm confused with is how type hinting creates a Project object that is then available in the update() method. Isn't type hinting simply saying "this method expects param 1 to be an Object of type Project"? i.e. nothing to do with dependency injection. Any hints would be awesome, thanks.
  3. SamC

    Ah, ok, thanks guys. I did wonder one other thing, there seems to be numerous ways to achieve something, like, which approach would you use, inject into a method, or into the constructor? Both work in my case here (only showing one method, there are more, but they do not ALL need the Project class, create() for example just returns a view). So would you (the Laracasts showing me how to do this way): namespace App\Http\Controllers; use Illuminate\Http\Request; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { public function show(Project $project) { return view('', compact('project')); } } ...OR (the way shown in @Wanze's link above from Laravel docs): namespace App\Http\Controllers; use Illuminate\Http\Request; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { protected $project; // Inject Project model here instead of on multiple methods public function __construct(Project $project) { $this->project = $project; } public function show($id) { $project = $this->project->findOrFail($id); return view('', compact('project')); } } Would one way be considered 'better' than the other way? Does it just depend on how many methods actually need the other class? i.e. what's the point of instantiating in the constructor if 3 methods need it, and 3 methods don't. That kind of thing? Not sure I like compact() either, it's not obvious to me (lack of experience?) what's actually being passed to the view. I know there are other ways. If you use artisan to set this up automagically: php artisan make:controller ProjectsController -r -m Project results with the former i.e. no constructor, which seems weird seeing as their docs say: i.e. using a constructor:
  4. SamC

    My needs are shall we say, basic. But CI/CD is something that interests me. I've seen a lot of travis files on various projects but no idea what they do tbh. I'm guessing it's like Buddy, but less point and click. I use buddy to sync files between a staging and production site, for pushing code from a gitlab repo > staging site (automatically when pushed from vscode) > production site (on a button click in buddy web UI). I'm guessing I can do all the same things with github. One concern would be them sucking me in with a 'free' promise, then start charging for it, like what just did for my invoicing! And just did the same... except they didn't just add a premium version, they took features OUT the free one and started charging for them. I didn't use github because it wasn't free for private repos, it was as simple as that. I tried bitbucket but IMHO, the UI was awful. Gitlab was much nicer, but I prefer Github. Now it's free, maybe I can try it out some more... and learn what travis does.
  5. SamC

    Hi Adrian I'm using GitLab for all my private stuff, worked fine so far. It also integrates nicely with Buddy (which is good for me because I don't know how to set up CI stuff manually). Why would this move by Github have you move from Gitlab? What would make Github a better choice for you?
  6. SamC

    Title says it all really. Is anyone else having trouble with the wifi on OSX Mojave? It's becoming a huge pita, It's fine, then it's super slow, then sometimes it's 'cant connect' on webpages, then it's fine again 5mins later. It just hung on a gIt push and I was like panic mode. It looks like some sort of DNS issue but not so good at troubleshooting on OSX. When it goes pear shaped, I check my android phone and the wifi is totally fine, the downstairs desktop (ethernet) is fine also. Anyone got any ideas or had similar problems? Thanks.
  7. SamC

    After trying @wbmnfktr suggestion of turning off bluetooth (I also deleted wifi and re-set it up), the wifi seems to be working fine for the last couple of days.... fingers crossed. Although crossing fingers and hoping for the best is no substitute for it actually working like it should!
  8. SamC

    I've been on windows since about win95 and I've never had any issues. Other than the ancient looking (IMHO) explorer and those yellow folders, I really enjoy it, now on win10 on the desktop. I actually had a surface laptop on order, then got all paranoid about the material staining up (I have eczema so my hands can be greasy with moisturizer). The order fell through when they failed to deliver it on time so I cancelled and got my money back, and bought the 2015 macbook. What do you use as a terminal on win10? I'm using cmder at the moment which seems to do the job. Mind you, I've got no idea what actually happened behind the scenes on initial setup.
  9. SamC

    Mine's a 2015 13" MBP. @ryan, thanks but I don't have the android file transfer installed. The only things I leave running are postgres server, docker and onedrive. I actually never turn the thing off because every time I did, I got this: on startup. I wasn't trying to upgrade or anything, just restarting. Actually, not sure if upgrade is the right word. Doesn't that imply something that's better? I started using a macbook in 2012 and never had any problems, now the number of issues seems to be creeping up and up. I guess I could quit moaning and buy a windows laptop but I expect more from such an expensive bit of gear. Anyway, I'll try the bluetooth suggestion tomorrow. Not sure what'll happen when I need to use my external (bluetooth) keyboard though.
  10. SamC

    I'll try that thanks. Didn't even know it was on tbh, I must have left it on after connecting to Sphero.
  11. SamC

    Have an awesome Christmas everyone! Maybe 2019 will be the year I get my big break... here's to hope
  12. I'm looking to combine two images into a single one and could do with some advice, or just where to start tbh. Image 1 (base): 600px x 400px Image 2 (will change): 80px x 100px Result: Image 3, which is image 1 with image 2 overlayed, offset x,y (50px, 50px from top left) Now, I guess I have two options, take image 1, and place image 2 on top of it, or make part of image 1 transparent, and put image 2 underneath. Image 1 will be a base image, and image 2 will change for each new generated image (image 3). Think of galleries of web design that have a macbook 'frame' around images. That sort of thing. I'm not sure a CSS solution would be robust enough here, too many things could go wrong with positioning. So I was looking at physically making a third image from the original two. I've read a few posts about using imagemagick and a few using GD but just after suggestions here on how to go about something like this? Any advice would be awesome, thanks.
  13. SamC

    @bernhard I was just looking at and the instructions are remarkably well explained. Just learned a bunch of stuff reading that.
  14. SamC

    So I know this is a PW forum but this is the off topic section so hopefully is ok. I've been learning Laravel for the past couple of weeks and hoping someone can help me out with this, it's driving me nuts! I built a small movie app using a 'diy MVC framework' from a Udemy course which was awesome. Now I'm porting it over to Laravel, and using Guzzle to query TMDB API to see how I can better organise my code (and learn Laravel at the same time). I'm getting an error on the page: http://movies.local/movies/list?name=denzel+washington ...which is: Undefined index: release_date (View: /Users/sam/www/movies.local/resources/views/movies.blade.php) ...pointing at this (on the laravel error page): <p>Release date: <?php echo e($movie['release_date']); ?></p> I'm outputting from my view thus (inside a loop, $movie represents a single movie in an array): <pre> <?php var_dump($movie); ?> </pre> <h3>{{ $movie['title'] }}</h3> <?php // THIS WORKS ?> <p>ID: {{ $movie['id'] }}</p> <?php // AND THIS... ?> <p>Release date: {{ $movie['release_date'] }}</p> <?php // THIS LINE IS BAD FOR SOME REASON... ?> <p>{{ $movie['overview'] }}</p> <?php // AND THIS... ?> ... when I remove the 'Release date' line, the page loads ok and the var_dump() spits out: array(17) { ["character"]=> string(13) "Robert McCall" ["credit_id"]=> string(24) "5588a41ec3a3683d500009cb" ["poster_path"]=> string(32) "/cQvc9N6JiMVKqol3wcYrGshsIdZ.jpg" ["id"]=> int(345887) ["video"]=> bool(false) ["vote_count"]=> int(1221) ["adult"]=> bool(false) ["backdrop_path"]=> string(32) "/z7noaCJ4KtmhwHw7QcNtnMMo4Qy.jpg" ["genre_ids"]=> array(3) { [0]=> int(28) [1]=> int(80) [2]=> int(53) } ["original_language"]=> string(2) "en" ["original_title"]=> string(15) "The Equalizer 2" ["popularity"]=> float(92.746) ["title"]=> string(15) "The Equalizer 2" ["vote_average"]=> float(6.2) ["overview"]=> string(183) "Robert McCall, who serves an unflinching justice for the exploited and oppressed, embarks on a relentless, globe-trotting quest for vengeance when a long-time girl friend is murdered." ["release_date"]=> string(10) "2018-07-20" ["custom_image_path"]=> string(63) "" } it can be seen quite clearly that the key 'release_date' does in fact exist. And the other keys work ok, and they're on the same level. And it gets weirder, if I replace the Blade: <p>Release date: {{ $movie['release_date'] }}</p> ...with <p>Release date: <?= (isset($movie['release_date'])) ? $movie['release_date'] : 'No date'; ?></p> ...then everything works fine, the date is output as it should be. But surely I don't need to check each key? I know it exists as the movies listed inside this loop are one that have a release date, it's been checked earlier in the process. Like, if I chuck in: <p>Rating: {{ $movie['vote_average'] }}</p> <p>Credit ID: {{ $movie['credit_id'] }}</p> ...then they display ok too. What's so special about this 'release_date' key? Or do I have a really huge face palm moment typo that I just can't see? Thanks for any advice. ps the actual page looks like this (when I use the plain PHP code with isset() check to output the release date):
  15. SamC

    Doh! You're totally right. Just found one right at the end: [45] => Array ( [character] => Humpty Dumpty [credit_id] => 52fe4cbcc3a36847f823c93b [vote_count] => 2 [video] => [popularity] => 1.49 [original_language] => en [vote_average] => 0.5 [id] => 167867 [title] => Happily Ever After: Fairy Tales for Every Child Mother goose big book of Rhymes [original_title] => Happily Ever After: Fairy Tales for Every Child Mother goose big book of Rhymes [backdrop_path] => [genre_ids] => Array ( ) [adult] => [overview] => Fairy tales have always been a source of family pleasure, for parents and children alike. Now, some of the best-loved classics are being re-told in this vibrantly original and musical animated series, Happily Ever After: Fairy Tales For Every Child. Each tale features a hip, contemporary all-star cast of voices and all-new songs the entire family will enjoy! Classic fairy tales become fresh and fun, told as if for the very first time. So share the magic and wonder with your children as we invite you to enter the wonder-filled world of Happily Ever After. Includes the following Fairy Tales: Mother Goose, A Rappin' & Rhymin' Special Pinocchio The Golden Goose The Pied Piper [poster_path] => /rSJSZiwyAVl165lmRXgNoUp4VWy.jpg [custom_image_path] => ) How this works is that I query the TMDB with a name (from the form), from that, you get the actor ID, from there the ID is used to get details about the actors, and everything they've starred in/directed etc.... there's no database involved at all (although in the future, I'd like it to build dynamically as the searches happen to cut down on API requests. You can only query 4 times a second at TMDB). The results from TMDB don't seem to be very consistent. With this 'release_date' key, it's either: 1) Exists and has value 2) Exists but no value 3) Doesn't exit at all I think, based on what I've already said, that I need to check values exist first before doing anything. Thanks @LostKobrakai
  16. Good luck @kongondo, although I haven't used it yet, Padloper looks pretty sweet.
  17. SamC

    Wow, thanks @horst that's an awesome reply! Nice one I'm also looking for something similar for an app outside PW. I found which I tried out locally. Seemed to do the job pretty well but I know next to nothing about image manipulation. Does anyone still use just plain ol' GD(2) anymore?
  18. I'm having some issues with CKEditor, tried following this: ...but nothing seems to change. I created the mystyles.js (exactly as the above link just to see what it does). My admin page looks like this: When I go to edit a body field, nothing has changed. The JS is this: CKEDITOR.stylesSet.add('mystyles', [ // Block-level styles { name: 'Heading 1', element: 'h1'}, { name: 'Heading 2', element: 'h2', attributes: { 'class': 'my-header'} }, { name: 'Heading 3', element: 'h3'}, { name: 'Introduction', element: 'p', attributes: { 'class': 'introduction'} }, // Inline styles { name: 'Link button', element: 'a', attributes: { 'class': 'button' } }, { name: 'Highlight', element: 'span', attributes: { 'class': 'highlight' } }, // Object styles { name: 'Stretch', element: 'img', attributes: { 'class': 'stretch' } }, ]); Now I guess some of my confusion is I don't actually know where these options would even appear to be selected. For example: { name: 'Heading 2', element: 'h2', attributes: { 'class': 'my-header'} }, Does this mean there should be a class 'my-header' in the 'styles' dropdown? In any case, it's not there, or anywhere to be seen. Pretty confused. I don't usually customize CKEditor but in this case I need to be able to select a ul list, then apply a class of 'generic-list'. I need to be able to do this via the dropdowns in the editor, rather than in the source code. And when I finally get this into the source code via the dopdown, I have ACF to contend with once the page saves. Not having a great deal of luck on that, tried ul(*), ul{*}, ul[*], doesn't seem to allow anything. Def running out of patience here, muchos frustration, so I thought I'd see if anyone can help to get me through this with my eyeballs intact. Thanks for any advice. ==EDIT== The file is present and is being loaded.
  19. SamC

    6 months later on my journey and I completely agree with this. Had to modify some jQuery the other day and it was super easy with a relatively decent background in plain JS now.
  20. SamC

    After a bit of research, I think this is one rabbit hole I'm not prepared to go down right now. Sticking to laragon on windows and mamp on osx. I'll go back over these suggestions when my current setup doesn't work for me anymore! But for now, my time is better spent carrying on with my programming. I like the look of this ^^ though. Thanks everyone
  21. I use MAMP on OSX and Laragon on Windows but I've recently been looking at Vagrant and Docker because my life isn't complicated enough and I need more confusion and frustration. Seriously though, what do people here use? Do you have any recommendations and reasons why it would be worth switching from a more 'fixed' environment. I've read docker might be less resource hungry but is trickier to get set up but I don't know the truth in this. Bearing in mind this is just localhost stuff for now but in the future, I am more likely to be involved in a team. Well, it's not all localhost, I have two live sites that I need to work on locally. I'm comfortable enough in XAMPP, MAMP, WAMP, Laragon etc. but Vargrant/Docker looks like a conceptual switch. I do however like the idea of being able to mimic a production environment. I'm also realistic, being 4 months into my JS/PHP learning, is this something that I need right now? Would it be more recommended to stick to the tools I know i.e. just ditch MAMP and try AMPPS. Right now, I'm in a situation where I have nothing on OSX (other than "php -S localhost:8000"). I wanted to install PW and try a few things out which lead me to looking at alternatives. Thanks for any advice
  22. SamC

    Thanks for the suggestions, I'll look into these this coming week Me reading that:
  23. SamC

    Yeah, and you can ignore things like "1 star of 5: didn't teach me how to make an facebook clone" in the comments for a 'Learn basic PHP' course. ^ this. I have anxiety which gets much worse without clear direction or when burning out spending hours upon hours on problems without breaks. This course has helped me massively to break up my learning and provided different techniques to use which has made programming fun again and much less stressful for me which is awesome. So glad @FrancisChung recommended this one.
  24. SamC

    I always do this: What grinds my gears is when hamburger menus are the only option on desktop sites (just for the sake of looking fancy), so I gotta click on it just to show the available options before I can choose something.
  25. SamC

    Don't you need to loop that page reference field (from your original example) if it's a list of tool pages? i.e. $lendoutpages = $pages->find("template=lendout, student_name=$page->id, sort=-lendout_time"); foreach($lendoutpages as $lendoutpage) { echo "<li><a href='{$lendoutpage->url}'>{$lendoutpage->lendout_time}:</a>"; foreach ($lendoutpage->tool as $single_tool_page) { echo "<b>{$single_tool_page->title}</b>"; } echo "</li>"; }; I'm not sure you need to use page->find() twice (as in your reworked example). Something like the above. This post may be useful: