Skip to content

Commit 79fdf86

Browse files
committed
Galleries Built, Users nearly Built
Signed-off-by: David Thorpe <[email protected]>
1 parent 7a5afd3 commit 79fdf86

19 files changed

+394
-17
lines changed

src/Davzie/LaravelBootstrap/Accounts/User.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ class User extends EloquentBaseModel implements LaravelUserInterface, Remindable
77
{
88
protected $table = 'users';
99

10-
// Never actually delete shit, just 'soft delete' that bad-boy
11-
protected $softDelete = true;
12-
1310
/**
1411
* The attributes excluded from the model's JSON form.
1512
*
@@ -43,7 +40,7 @@ public function getAuthIdentifier()
4340
* Get the full name of the user
4441
* @return string
4542
*/
46-
public function getFullName(){
43+
public function getFullNameAttribute(){
4744
return $this->first_name.' '.$this->last_name;
4845
}
4946

src/Davzie/LaravelBootstrap/Accounts/UserRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php namespace Davzie\LaravelBootstrap\Accounts;
2-
use Davzie\LaravelBootstrap\EloquentBaseRepository;
2+
use Davzie\LaravelBootstrap\Core\EloquentBaseRepository;
33

44
class UserRepository extends EloquentBaseRepository implements UserInterface
55
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php namespace Davzie\LaravelBootstrap\Galleries;
2+
use Davzie\LaravelBootstrap\Core\EloquentBaseModel;
3+
use Davzie\LaravelBootstrap\Abstracts\Traits\TaggableRelationship;
4+
use Davzie\LaravelBootstrap\Abstracts\Traits\UploadableRelationship;
5+
6+
class Galleries extends EloquentBaseModel
7+
{
8+
9+
use TaggableRelationship; // Enable The Tags Relationships
10+
use UploadableRelationship; // Enable The Uploads Relationships
11+
12+
/**
13+
* The table to get the data from
14+
* @var string
15+
*/
16+
protected $table = 'galleries';
17+
18+
/**
19+
* These are the mass-assignable keys
20+
* @var array
21+
*/
22+
protected $fillable = array('title', 'slug', 'description');
23+
24+
protected $validationRules = [
25+
'title' => 'required',
26+
'slug' => 'required|unique:galleries,id,<id>'
27+
];
28+
29+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php namespace Davzie\LaravelBootstrap\Galleries;
2+
3+
interface GalleriesInterface {
4+
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php namespace Davzie\LaravelBootstrap\Galleries;
2+
use Davzie\LaravelBootstrap\Core\EloquentBaseRepository;
3+
use Davzie\LaravelBootstrap\Abstracts\Traits\TaggableRepository;
4+
5+
class GalleriesRepository extends EloquentBaseRepository implements GalleriesInterface
6+
{
7+
8+
use TaggableRepository;
9+
10+
/**
11+
* Construct Shit
12+
* @param Galleries $galleries
13+
*/
14+
public function __construct( Galleries $galleries )
15+
{
16+
$this->model = $galleries;
17+
}
18+
19+
}

src/Davzie/LaravelBootstrap/Posts/PostsInterface.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,4 @@ public function getAllByDateAsc();
1414
*/
1515
public function getAllByDateDesc();
1616

17-
/**
18-
* Get all posts that have a tag of the type passed in
19-
* @return Posts
20-
*/
21-
public function getAllByTag( $tag );
22-
2317
}

src/bindings.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
return new Davzie\LaravelBootstrap\Posts\PostsRepository( new Davzie\LaravelBootstrap\Posts\Posts );
66
});
77

8+
// The Posts Bindings
9+
App::bind('Davzie\LaravelBootstrap\Accounts\UserInterface', function(){
10+
return new Davzie\LaravelBootstrap\Accounts\UserRepository( new Davzie\LaravelBootstrap\Accounts\User );
11+
});
12+
813
// The Settings Bindings
914
App::bind('Davzie\LaravelBootstrap\Settings\SettingsInterface', function(){
1015
return new Davzie\LaravelBootstrap\Settings\SettingsRepository( new Davzie\LaravelBootstrap\Settings\Settings );
@@ -23,4 +28,9 @@
2328
// The Uploads Bindings
2429
App::bind('Davzie\LaravelBootstrap\Uploads\UploadsInterface', function(){
2530
return new Davzie\LaravelBootstrap\Uploads\UploadsRepository( new Davzie\LaravelBootstrap\Uploads\Uploads );
31+
});
32+
33+
// The Uploads Bindings
34+
App::bind('Davzie\LaravelBootstrap\Galleries\GalleriesInterface', function(){
35+
return new Davzie\LaravelBootstrap\Galleries\GalleriesRepository( new Davzie\LaravelBootstrap\Galleries\Galleries );
2636
});

src/controllers/BlocksController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function __construct( BlocksInterface $blocks )
1616
{
1717
$this->model = $blocks;
1818
parent::__construct();
19-
// dd( $this->model->getAllByTag('shit') );
2019
}
2120

2221
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php namespace Davzie\LaravelBootstrap\Controllers;
2+
use Davzie\LaravelBootstrap\Galleries\GalleriesInterface;
3+
4+
class GalleriesController extends ObjectBaseController {
5+
6+
/**
7+
* The place to find the views / URL keys for this controller
8+
* @var string
9+
*/
10+
protected $view_key = 'galleries';
11+
12+
/**
13+
* Construct Shit
14+
*/
15+
public function __construct( GalleriesInterface $galleries )
16+
{
17+
$this->model = $galleries;
18+
parent::__construct();
19+
}
20+
21+
}

src/controllers/UsersController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php namespace Davzie\LaravelBootstrap\Controllers;
2+
use Davzie\LaravelBootstrap\Accounts\UserInterface;
3+
4+
class UsersController extends ObjectBaseController {
5+
6+
/**
7+
* The place to find the views / URL keys for this controller
8+
* @var string
9+
*/
10+
protected $view_key = 'users';
11+
12+
/**
13+
* Construct Shit
14+
*/
15+
public function __construct( UserInterface $users )
16+
{
17+
$this->model = $users;
18+
parent::__construct();
19+
}
20+
21+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class CreateGalleriesTable extends Migration {
5+
6+
/**
7+
* Run the migrations.
8+
*
9+
* @return void
10+
*/
11+
public function up()
12+
{
13+
if ( !Schema::hasTable('galleries') )
14+
{
15+
Schema::create('galleries', function($table)
16+
{
17+
18+
$table->engine = 'InnoDB';
19+
20+
$table->increments('id');
21+
$table->string('title',255);
22+
$table->string('slug',255);
23+
$table->unique('slug');
24+
$table->text('description');
25+
$table->index('id');
26+
$table->timestamps();
27+
28+
});
29+
}
30+
}
31+
32+
/**
33+
* Reverse the migrations.
34+
*
35+
* @return void
36+
*/
37+
public function down()
38+
{
39+
Schema::drop('galleries');
40+
}
41+
42+
}

src/routes.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
// Filter all requests ensuring a user is logged in when this filter is called
77
Route::filter('adminFilter', 'Davzie\LaravelBootstrap\Filters\Admin');
88

9-
Route::controller( $urlSegment.'/settings' , 'Davzie\LaravelBootstrap\Controllers\SettingsController' );
10-
Route::controller( $urlSegment.'/blocks' , 'Davzie\LaravelBootstrap\Controllers\BlocksController' );
11-
Route::controller( $urlSegment.'/posts' , 'Davzie\LaravelBootstrap\Controllers\PostsController' );
12-
Route::controller( $urlSegment , 'Davzie\LaravelBootstrap\Controllers\DashController' );
9+
Route::controller( $urlSegment.'/users' , 'Davzie\LaravelBootstrap\Controllers\UsersController' );
10+
Route::controller( $urlSegment.'/galleries' , 'Davzie\LaravelBootstrap\Controllers\GalleriesController' );
11+
Route::controller( $urlSegment.'/settings' , 'Davzie\LaravelBootstrap\Controllers\SettingsController' );
12+
Route::controller( $urlSegment.'/blocks' , 'Davzie\LaravelBootstrap\Controllers\BlocksController' );
13+
Route::controller( $urlSegment.'/posts' , 'Davzie\LaravelBootstrap\Controllers\PostsController' );
14+
Route::controller( $urlSegment , 'Davzie\LaravelBootstrap\Controllers\DashController' );
1315

1416
/** Include IOC Bindings **/
1517
include __DIR__.'/bindings.php';

src/views/galleries/edit.blade.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@extends('laravel-bootstrap::layouts.interface-edit')
2+
3+
@section('title')
4+
Edit Gallery: {{ $item->title }}
5+
@stop
6+
7+
@section('heading')
8+
<h1>Edit Gallery: <small>{{ $item->title }}</small></h1>
9+
@stop
10+
11+
@section('form-items')
12+
13+
<div class="form-group">
14+
{{ Form::label( "title" , 'Gallery Title' , array( 'class'=>'col-lg-2 control-label' ) ) }}
15+
<div class="col-lg-10">
16+
{{ Form::text( "title" , Input::old( "title", $item->title ) , array( 'class'=>'form-control' , 'placeholder'=>'Gallery Title' ) ) }}
17+
</div>
18+
</div>
19+
<div class="form-group">
20+
{{ Form::label( "slug" , 'Gallery Key' , array( 'class'=>'col-lg-2 control-label' ) ) }}
21+
<div class="col-lg-10">
22+
{{ Form::text( "slug" ,$item->slug , array( 'class'=>'form-control' , 'disabled'=>'disabled' ) ) }}
23+
</div>
24+
</div>
25+
<div class="form-group">
26+
{{ Form::label( "description" , 'Gallery Content' , array( 'class'=>'col-lg-2 control-label' ) ) }}
27+
<div class="col-lg-10">
28+
{{ Form::textarea( "description" , Input::old( "description" , $item->description ) , array( 'class'=>'form-control rich' , 'placeholder'=>'Gallery Description' ) ) }}
29+
</div>
30+
</div>
31+
32+
@stop

src/views/galleries/index.blade.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@extends('laravel-bootstrap::layouts.interface')
2+
3+
@section('title')
4+
Manage Image Galleries
5+
@stop
6+
7+
@section('content')
8+
9+
<h1>Manage Image Galleries</h1>
10+
<p>Image galleries are images separated into their own little section.</p>
11+
12+
13+
{{-- The error / success messaging partial --}}
14+
@include('laravel-bootstrap::partials.messaging')
15+
16+
@if( !$items->isEmpty() )
17+
<table class="table table-condensed">
18+
<thead>
19+
<tr>
20+
<th>ID</th>
21+
<th>Title</th>
22+
<th>Slug</th>
23+
<th>Created</th>
24+
<th>&nbsp;</th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
@foreach($items as $item)
29+
<tr>
30+
<td><a href="{{ $edit_url.$item->id }}">{{ $item->id }}</a></td>
31+
<td><a href="{{ $edit_url.$item->id }}">{{ $item->title }}</a></td>
32+
<td><a href="{{ $edit_url.$item->id }}">{{ $item->slug }}</a></td>
33+
<td><a href="{{ $edit_url.$item->id }}">{{ $item->created_at }}</a></td>
34+
<td>
35+
<div class="pull-right">
36+
<a href="{{ $edit_url.$item->id }}" class="btn btn-sm btn-primary">Edit Item</a> <a href="{{ $delete_url.$item->id }}" class="btn btn-sm btn-danger">Delete Item</a>
37+
</div>
38+
</td>
39+
</tr>
40+
@endforeach
41+
</tbody>
42+
</table>
43+
@else
44+
<div class="alert alert-info">
45+
<strong>No Items Yet:</strong> You don't have any items here just yet. Add one using the button below.
46+
</div>
47+
@endif
48+
<a href="{{ $new_url }}" class="btn btn-primary pull-right">New Item</a>
49+
@stop

src/views/galleries/new.blade.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@extends('laravel-bootstrap::layouts.interface-new')
2+
3+
@section('title')
4+
Create New Image Gallery
5+
@stop
6+
7+
@section('heading')
8+
<h1>Create New Image Gallery</h1>
9+
@stop
10+
11+
@section('form-items')
12+
13+
<div class="form-group">
14+
{{ Form::label( "title" , 'Gallery Title' , array( 'class'=>'col-lg-2 control-label' ) ) }}
15+
<div class="col-lg-10">
16+
{{ Form::text( "title" , Input::old( "title" ) , array( 'class'=>'form-control' , 'placeholder'=>'Gallery Title' ) ) }}
17+
</div>
18+
</div>
19+
<div class="form-group">
20+
{{ Form::label( "slug" , 'Gallery Key' , array( 'class'=>'col-lg-2 control-label' ) ) }}
21+
<div class="col-lg-10">
22+
{{ Form::text( "slug" , Input::old( "slug" ) , array( 'class'=>'form-control' , 'placeholder'=>'Gallery Slug' ) ) }}
23+
</div>
24+
</div>
25+
<div class="form-group">
26+
{{ Form::label( "description" , 'Gallery Content' , array( 'class'=>'col-lg-2 control-label' ) ) }}
27+
<div class="col-lg-10">
28+
{{ Form::textarea( "description" , Input::old( "description" ) , array( 'class'=>'form-control rich' , 'placeholder'=>'Gallery Description' ) ) }}
29+
</div>
30+
</div>
31+
32+
@stop

src/views/layouts/interface-edit.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
6565
if( this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0 ){
6666
// Submit dat form
67-
// $('#item-form').submit();
67+
$('#item-form').submit();
6868
}
6969
7070
});

0 commit comments

Comments
 (0)