PHP - Some Questions About Laravel
1. If I start a new project, should I use Laravel 5.0(dev) or 4.2?
2. How easy is it to upgrade from between major version like that?
3. Any design recommendations for daily with authentication and accounts?
Similar Tutorialshow do i install laravel ?
using composer it asks for php in my local files? do i have to download something for this?
i am just getting into frameworks like larvel
I am really struggling with the logic aspect of my application. I can't picture the structure and get it clear in my mind. As a result, I can't code anything because I'm second-guessing myself at every turn.
My application is pretty simple in reality. It's an application that keeps a record of all the different 'contracts'/'agreements' that my colleagues have signed. Some will have signed three or four depending on what systems they are working on.
The application will run a cron, daily, and send out an email to anyone who's contract/agreement is about to expire with an invite for them to renew it.
I have already built an application that has a login system and authentication (using Laravel). It was my first Laravel effort and I did it using a tutorial from YouTube. I figured I could use the one login from that to act as the administrator for this whole application. Once the administrator is in, they will be presented with a panel to do various things. This is the part I am stuck on. What do you all think of my "logic"?
Here are the basic routes (forgetting the auth stuff which is already done);
/contracts - to see a list of all the contact templates out there.
/contracts/{contract-id} - to view the specific contract template
/contracts/create - GET and POST to be able to add new contract templates for other systems
/people - view all my colleagues on one page
/people/{person-id} - view a specific colleague and all the contracts they have signed
/people/create - GET and POST for this too to be able to add new colleagues to the system
/people/{person-id}/create-new-contract - so this would add a record in to a third table which joins info from the people table and the contracts table to make a list of unique contract agreements for each person and their expiry date. GET and POST for this as well I suppose. Even as I'm writing this, I don't know if this will be needed because I might have an emailing class that might do this job better? Hence the writing of this post!
/agreements/renew/{renew-code} - This will create a new record in the table and amend the old one to show that the previous agreement has expired and that a new one for the next 365 days is in place.
As you can probably tell.. I am struggling a bit. Is there any advice you can give me to help me mentally map out my application before I start coding? I just want to get it right..
Hi.
My sys admin guy has informed me that installing composer is unlikely. They're a bit jumpy about security around here.
I tried to download and run Laravel on it's own but I'm getting errors when I go to http://example.com/t...laravel/public/
Warning: require(/var/www/html/test/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/test/laravel/bootstrap/autoload.php on line 17 Fatal error: require(): Failed opening required '/var/www/html/test/laravel/bootstrap/../vendor/autoload.php' (include_path='.:/php/includes:/var/www/html/php/includes:/jpa/release/jpa/includes:/usr/share/pear:/usr/share/php/phpmailer:/apache/htdocs/applications/surveys/Includes:/var/lib/ZF1/library') in /var/www/html/test/laravel/bootstrap/autoload.php on line 17I'm very new to Laravel and I am basically assuming that the reason for these errors is because i haven't installed all the various dependancies. And that you can only install all the dependancies through Composer. Is this the case? I downloaded the Laravel framework from GitHub Unfortunately.. My only real experience of PHP Frameworks is CodeIgniter. So I've never expoled/used "packages" or "dependancies" and don't really know where they are, or where they go, or what they do! I managed to get Laravel up and running on my personal computer (using Composer).... But, as I've said, I might not be able to do this on my day job server. Any tips? ----- Update ----- Is there a chance I am just misunderstanding the word "Dependancies"? It's not a word I often use. Does it just mean "The PHP files that make up the Laravel Framework"? Edited by Korferer, 19 November 2014 - 08:11 AM. Hello everyone, I have a PHP Laravel CRUD application I made where I am using MVC style. I have controllers views and models. My database migration is made and my table in the database is made with php artisan migrate. I am using php 7.3 and laravel 5.8. On my create view I go to create a single object in my database and my errors are thrown saying nothing in text box (no input) If I comment out the errors then just I click my submit button and nothing happens nothing is entered into my db. I have looked at many different crud examples and I am not sure why my object isn’t being created. Here is what I have
//view create @section('main') <section id="section-content" class="text-center"> <div class="container contentdiv rounded"> <div class="row"> <div class="col-md-12"> <div class="pb-2 mt-4 mb-2 border-bottom clearfix"> <h2>Create Contact</h2> </div> <div > <a class="btn btn-success" href="{{route('contacts.index')}}">Back</a> </div> </div> <!-- <div class="col-md-10 mx-auto"> @if($errors->any()) <div class="alert alert-danger"> <ul> @foreach($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div><br /> @endif </div> --> <div class="row"> <div class="col-md-10 mx-auto mt-3"> <form method="POST" action="{{ route('contacts.store') }}"> @csrf <div class="form-group row"> <label for="txtfn" class="col-sm-3"><b>First Name:</b></label> <div class="col-sm-9"> <input type="text" class="form-control" name="txtfn" id="txtfn"/> </div> </div> <div class="form-group row"> <label for="txtln" class="col-sm-3"><b>Last Name:</b></label> <div class="col-sm-9"> <input type="text" class="form-control" name="txtln" id="txtln"/> </div> </div> <div class="form-group row"> <label for="txtem" class="col-sm-3"><b>Email:</b></label> <div class="col-sm-9"> <input type="text" class="form-control" name="txtem" id="txtem"/> </div> </div> <button type="submit" class="btn btn-primary">Create Contact</button> </form> </div> </div> </div> </section> //controller namespace App\Http\Controllers; use App\Contact; use Illuminate\Http\Request; class ContactController extends Controller { public function store(Request $request) { $request->validate([ 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required' ]); $contact = new Contact([ 'first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'job_title' => $request->get('job_title'), 'city' => $request->get('city'), 'country' => $request->get('country') ]); $contact->save(); return redirect('/contacts')->with('success', 'Contact saved!'); } public function index() { $contacts = Contact::all(); return view('contacts.index', compact('contacts')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('contacts.create'); } // model namespace App; use Illuminate\Database\Eloquent\Model; class Contact extends Model { protected $fillable = [ 'first_name', 'last_name', 'email', 'city', 'country', 'job-title' ]; } My env is setup correctly I just don’t get the not creating object. I'm looking for one or two talented Laravel guys in the Dallas area who write clean code, document well, and love pushing the limits of their own abilities. It is important that the developers we hire are local. Please do not respond if you do not live in the Dallas area.
Preferred knowledge
- Laravel
- AngularJS
- NodeJS
- jQuery
- MySQL
- HTML/CSS
- e-Commerce
- Paranoid about security
- Performance minded
We are developing applications that will process millions of dollars in transactions every month. Performance, security, and the ability to scale is paramount.
Thank you
I work on laravel app with my sql database mvc I modify some thing on html pages and then i run my app then write php artisan serve but after site run i dont see changes on html can you please help me I have started a project using laravel. I am in the process of builing User groups and permissions in the admin dashboard.
I have uploaded a snapshot of my views to which i want to restrict access. i want to structure it to be completely dynamic
views.PNG 9.41KB
0 downloads
//my controller <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; class homeController extends Controller { public function index() { $employee = DB::table('employee')->orderBy('id','desc')->get(); $department = DB::table('department')->orderBy('id','desc')->get(); return view('index', ['employee' => $employee , 'department' => $department]); } } //my routes Route::get('index','homeController@index'); //my view using blade temmplating engine @foreach($employee as $emp) <div class="employee"> <b>{{ $emp->name }} </b> <a href="employee/{{ $emp->id }}"> <p class="intro">{{ substr($emp->intro ,0, 50) }}...</p> </a> </div> @endforeach @foreach($department as $dep) <div class="department"> <b>{{ $dep->name }} </b> <a href="department/{{ $dep->id }}"> <p class="desc">{{ substr($dep->description ,0, 100) }}...</p> </a> </div> @endforeach I want to fetch using ajax, how can i do it, teach/help me This should be a simple task I am just not fully grasping laravel yet. I have my controllers view and models setup. I want to use my users.destroy route to delete my row in the db. But I want to do it a certain way. I want to have an alert show In my alert area on my page asking to confirm the deletion of a certain user. Im assuming I need to pass the user id in a session to an alert to confirm my delete on a delete button click. Click 1 button to open an alert on the top of my page if I click confirm it calls user.destroy.
<div class="container"> <div class="row justify-content-center"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <h4>View All Users</h4> @if(session()->get('success')) <div class="alert alert-success"> {{ session()->get('success') }} </div> @endif @if(session()->get('danger')) <div class="alert alert-danger"> {{ session()->get('danger') }} </div> @endif </div> <div class="card-body"> <div class="text-center my-2"> <a href="{{ route('register') }}" class="btn btn-primary">New User</a> </div> <div> <table class="table table-striped table-bordered"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Email</th> <th>Username</th> <th colspan="2">Actions</th> </tr> </thead> <tbody> @foreach($users as $user) <tr> <th>{{$user->id}}</th> <td>{{$user->name}}</td> <td>{{$user->email}}</td> <td>{{$user->username}}</td> <td class="text-center"> <a href="{{ route('users.show', $user->id) }}" class="btn btn-primary mr-3">Show</a> <a href="{{ route('users.edit', $user->id) }}" class="btn btn-info text-white ml-3">Edit</a> <a href="#" class="btn btn-danger">Delete</a> </td> </tr> @endforeach </tbody> </table> public function destroy($id) { User::find($id)->delete(); return redirect()->route('users.index')->with('success','User Deleted'); } Route::resource('users', 'UserController');
Hi there I've recently been working on a Laravel project. It's a project I've been drafted in to work on and I've not used Laravel before. My question is one of what is considered good practice. In this project the controllers pass whole models back to the view. For instance, its the norm on the project to pass back a whole booking model just to get at a couple of attributes like booking->id and booking->name. As these attributes represent database columns it feels a bit wrong to pass these around because you're effectively coupling the view to the structure of the database. I know behind the scenes Laravel is using a magic method to access the properties so you could argue they are wrapped in a method and therefore don't expose the direct database structure to views. So the question is, would you pass database models directly to views in this way? Or is it 'better' to map those models to an intermediary model that is dedicated to the view (a sort of dto)? Thanks,
Drongo Hi y'all. First off, posting this here to hopefully avoid the noise that's happening in the Applications sub-forums, so mods please feel free to move if it's too inappropriate here. Anyway, I'm currently doing a skills assessment for a potential new job in Laravel - if I wasn't using Laravel I would've been done hours ago, but one of the requirements is Laravel. Honestly, for the most part I dig it - it's pretty simple, despite it's reliance on magic. Anyway, I've written a couple API routes and when I visit them in the browser everything works exactly as expected and desired. However, when I run the pre-built test file, I get a Symfony\Component\HttpKernel\Exception\NotFoundHttpException for /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php. The route as defined in api.php: use App\Http\Controllers\User; /** * I tried using a Resource Collection here - there's obviously something about those * that I'm missing, because it actively refused to do anything worthwhile. I'd pass in * UserModel::with('timelogs')->get() like I use in \App\Http\Controllers\User::getTotalSeconds(), * and it didn't care. Just printed out absolute garbage, no matter what I fed to it. */ Route::get('/user-timelogs', function(Request $request) { $u = new User; return $u->getTotalSeconds(); }); And the controller code: namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User as UserModel; class User extends Controller public function getTotalSeconds() { $users = UserModel::with('timelogs')->get(); $ret = []; foreach($users as $user){ array_push($ret, [ 'user_id' => $user->id, 'seconds_logged' => $this->calculateTime($user->timelogs) ]); }; return json_encode($ret); } private function calculateTime($logs) { $totalTime = 0; foreach($logs as $log){ $totalTime += $log->seconds_logged; } return $totalTime; } } The model file for good measu namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'id', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function timelogs() { return $this->hasMany('App\Timelog'); } } Again, when I visit localhost/api/user-timelogs, the user IDs and correct total of seconds is right there. It's just in the test file that it's an issue. Anybody have any ideas? Edited September 21, 2019 by maxxdwas totally not done typing... I am new to the Laravel Framework, doing an internship and at the very end.. I need some assistance please with some try catch error, Its supposed to throw an error if the site name is already in the database.. If someone could help me please and thank you ..
```
public function create() { return View::make('edit.create'); } public function edit( $clientsite ) { return View::make('edit.edit', compact('clientsite')); } public function saveCreate() { $input = Input::all(); try { $clientsite = new ClientSite; $clientsite->siteName = $input['siteName']; $clientsite->description = $input['description']; $clientsite->launchDate = $input['launchDate']; $clientsite->save(); //ClientSite::whereSiteName($clientsite->siteName)->first(); ClientSite::where('siteName', $clientsite->siteName)->first(); $clientID = $clientsite['clientID'];//getting clientID for use in join query //queries for retrieving features of each group for the selected client $clientFeatures = DB::table('features')->join('clientFeatures', function($join) use($clientID) { $join->on( 'clientFeatures.featureID', '=', 'features.featureID') ->where('clientFeatures.clientID', '=', $clientID); })->get(); $groupIDs = array(); foreach ($clientFeatures as $c) { $groupIDs[] = $c->groupID; } catch(\Illuminate\Database\QueryException $e) { return View::make('profiles.clientProfiles')->with('clientsite',$clientsite) ->with('groupIDs',$groupIDs) ->with('clientFeatures',$clientFeatures) ->with('status','<strong>'.$siteName.' Site already exist!</strong>'); ; } ``` https://github.com/webdevdea/MyDyn ( i have not pushed these changes because I have an error ) I currently have an array that I've built that dumps like this:
0 => array:11 [▼ "category_code" => "123" "category_name" => "Testing" "category_description" => "This is a test category" 19738 => array:5 [▼ "identifier" => "720368842943" "description" => Test Description One "count" => 4 "details" => array:2 [▼ 0 => array:3 [▼ "detail_code" => "2751" "detail_code2" => "43" "detail_specifier" => "Detail One" ] 1 => array:3 [▼ "detail_code" => "2681" "detail_code2" => "9" "detail_specifier" => "Detail Two" ] ] "prices" => array:1 [▼ "01" => "1129.00" ] ] 19739 => array:5 [▼ "identifier" => "720368844121" "description" => "Test Description Two" "count" => 4 "details" => array:2 [▼ 0 => array:3 [▼ "detail_code" => "2751" "detail_code2" => "43" "detail_specifier" => "Detail One" ] 1 => array:3 [▼ "detail_code" => "2681" "detail_code2" => "9" "detail_specifier" => "Detail Two" ] ] "prices" => array:1 [▼ "01" => "1490.00" ] ] I'm using laravel excel in order to export that as an excel file, but it's not quite working the way I intend When it exports to excel I only get the top level info: 123 | Testing | This is a test category But I want to get that info as a header and then each subsequent product for that category as a row, so with the example above it would look like:
123 | Testing | This is a test category Here's the excel code with the array I'm using, which is dumped above: $allCategoryResult= array(); foreach($prices->categories as $category){ $categoryItem = array(); $categoryItem["category_code"] = $category->category_code; $categoryItem["category_name"] = $category->category_name; $categoryItem["category_desc"] = $category->category_desc; foreach($category->skus as $sku){ $skuItem = array(); $skuItem["identifier"] = $sku->sku_info->identifier; $skuItem["description"] = $sku->sku_info->item->description; $skuItem["count"] = $sku->sku_info->item->item_type->count; $skuItem["details"] = array(); foreach ($sku->sku_info->details as $details) { $detailsItem = array(); $detailsItem["detail_code"] = $details->detail_code; $detailsItem["detail_code2"] = $details->detail_code2; $detailsItem["detail_specifier"] = $details->detail_specifier; $skuItem["details"][] = $detailsItem; } $skuItem["prices"] = get_object_vars($sku->prices); $itemCode = $sku->sku_info->item->item_code; $categoryItem[$itemCode] = $skuItem; } $allCategoryResult[] = $categoryItem; } $name = 'Test Export'; $build = Excel::create($name, function ($excel) use ($allCategoryResult) { $excel->setTitle('Test Export'); $excel->sheet('Test Export', function ($sheet) use ($allCategoryResult) { $sheet->fromArray($allCategoryResult);
Europe's biggest gaming company are looking to take on up to 10 PHP Developers to join their expanding development team working on new game releases.
They can offer relocation assistance and most interviews take place purely over Skype, or they can fly you over if required.
Its an English speaking company and could be making you an offer in the next week!
Please email me @ stuart.day@quantica.co.uk asap.
Hello everyone, I have been doing web developing for a little while and just recently decided to make the leap to developing standalone applications. I started learning C++ and JAVA for this purpose, but quickly learned that PHP can also be used to this end, and since I am quite familiar with PHP, I thought it would make sense to start with PHP GTK. But before I jump right in, I have a few questions that I would greatly appreciate some answers for: Does PHP have any significant advantages/disadvantages over lower level languages such as C++ ? I would imagine that PHP being originally designed for web programming would be less suited for stand alones. I'm a little confused as to whether the GTK is a graphical user interphase software, the likes of QT and Netbeans, or is it a markup language like HTML, where the widgets are generated with text commands? Please I need a little clarification on that. Also are there any other tools that need to be downloaded to get started besides the GTK? Finally, am I supposed to learn OOP PHP to get going or is traditional procedural PHP sufficient? Answers to any or all of the above questions and any other advice would be highly appreciated. Thanks. Hi. I'll like to ask few questions about PHP, as I think they are related to it.
I've came across some webpages, what I've spotted is that a webpage displays content but each "page" has different argument and there is no filename.
For example:
"http://www.website.com/?home" is home-like webpage, by changing "/?home" to "/?anotherpage" land me on some other webpage on their website and so on. My question is how is it done? Is it done from PHP?
Another question I wanted to ask is.. I went on InvisionPower.Board forum (such as this PHP Freaks ). How to force "folders" to be displayed as "files"?
For example:
"http://forums.phpfre...ks-on-facebook/" which links to a thread.
Thanks in advance
Howdy, I am new to SEO. Could you please help me? 1. I like to post programming tutorials to both my website & various programming forums. Is that going to screw up my website's ranking in Google? 2. My editor of my history website who sometimes posts essays there also posts them in some history forums. Is that bad for SEO? 3. I made a Facebook page for my history website. It says there "Promote your page" basically you pay $5 for around 100 likes. Has anyone tried that? Does it work? Because $5 seems like little money for additional 100 likes which will increase the traffic considerably. Thank you so much for the help! I've been coding PHP for some time and would consider myself to be at an intermediate level. I can write code to do what I need but it's probably not the best way to do it. I rarely see any code that I am not able to read, understand, or follow. I've created modifications for everything from vBulletin, WordPress, Kayako Support Suit, Magento, and more. However, I've never really built a strong understanding around OOP. For example, let say you have the following classes: _main - db - admin - - modules - - - dashboard How would you share the db connection with the dashboard class? I've been trying to read up on Dependency Injections and Singletons but I haven't found an article that has explained it on a level that I can understand. I get a feeling that most people who use OOP in PHP have a background in Java or C++ and are much more familiar with everything. Could someone please explain this to me in simple terms or link me to an extremely well explained article that I'd be able to understand without a background in computer science? Thanks I basically have a picture uploading system for users. I have two questions: 1) What CHMOD should I use for the folders that are there for uploading files to? Currently it is 755, but I want it to be accessible and safe. 2) When I use the standard mkdir() function to create folders in my main parent folder, the folders don't get created. Is this because my parent folder is CHMOD 755? Thanks |