Jump to content

Search the Community

Showing results for tags 'controller'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hi everyone, So I'm relatively new to OO PHP and moreover, OO PHP with MVC design pattern. This may be a largeish post so please bear with me on this one! So here is a scenario that I'd like to understand. There are likely multiple ways to go about this, but it'd be nice to see what is said. I'll include what I think should be the solution here and hopefully i'll get some feedback about it. Scenario: A page needs to display a list of "parts" for a car. A database table already exists with these parts. The list of parts on the page need to be ordered by name on first load, but then can be re-ordered by users using a drop down list. They can also be filtered, and searched. A page also exists to display a single car part. What I think should be, and what i'm struggling with: Model: I will have a "part" object which represents an individual car part. The part object will use a database abstraction layer. On "new Part()" will generate an empty object. ->Load( id ) will load an individual part. Controller: I do not know how I would implement this. I know it would contain methods to Filter(), Search() and Order() and that would directly access the Model. View: I am lost here too, I need to display a list of car parts, and on another page, a single car part. I understand I should use the same Model for both. However I do not see how I would list the parts. Some Questions: Should I have another "model" that is a list of the "Part" model called PaetListModel, or should "Part" be able to generate that list? I clearly should have 2 views, one for singular part, one for list of parts. Should the view access the model to generate the list before using the data for output? Should the controller be used in the view instead of the model to generate the initial list (or singular) on page load? Should the filter functions in the controller reload the "PartsList" from wherever our list is stored? I think the most important question for me though is: How would YOU implement the above green scenario? I would like to learn from peoples examples so I get an idea of what road to follow
  2. Hi everyone I'm in learning laravel, really a newbie. It's seems somehow I can't pass the variables from controllers to view. So this is what I've got config/route.php Route::get('/' , "PagesController@link"); Route::get('pg' , "PagesController@link"); Route::get('pg/{link}' , 'PagesController@link'); controllers/PagesController.php public function link($link = 'index') { // option 1 return "--->" . $link; // option 2 return View::make('pages.index' , array('link' => $link)); // option 3 return View::make('pages.index')->with('link', $link); // option 4 return View::make('pages.index' , compact('link')); } views/pages/index.blade.php @extends('layouts.frontend') @section('title') @parent - Index file @stop @section('content') <article> <header>This is the {{ $link }}</header> <p>And this is the main body of {{ $link }} file</p> </article> @stop views/pages/layouts/frontend.blade.php <!doctype html> <html> <head> <meta charset="utf-8"> <title> @section('title') Lar4 Test @show </title> {{ HTML::style('css/frontend.css') }} </head> <body> <header id="header"> <div id='banner'> </div> <nav> {{ HTML::link('pg' , 'Home') }} {{ HTML::link('pg/about' , 'About Us') }} </nav> </header> <section> @yield('content') </section> <aside> </aside> <footer> </footer> </body> </html> So if I browse to <site>/pg/sometext only option 1 will work (shows "---->sometext"), all others will thrown an error "Undefined variable: link". If I comment both {{ $link }}, both layout and index views are successfully rendered. Any idea of what am I doing wrong?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.