-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #626 from statonlab/624-recent-updates-feed-on-mai…
…n-page 624 recent updates feed on main page
- Loading branch information
Showing
24 changed files
with
892 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Treet; | ||
|
||
class TreetController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$this->validate($request, [ | ||
'limit' => 'nullable|integer|min:6|max:90', | ||
]); | ||
|
||
$limit = $request->limit ?: 10; | ||
|
||
$treets = Treet::select(['id','app_name', 'image_path', 'description', 'url', 'created_at']) | ||
->orderBy('created_at', 'desc') | ||
->limit($limit) | ||
->get(); | ||
|
||
$treets->map(function ($treet) { | ||
$treet->date = $treet->created_at->format('m/d/y'); | ||
}); | ||
|
||
return $this->success($treets); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
*/ | ||
public function create(Request $request) | ||
{ | ||
$this->authorize('create', Treet::class); | ||
|
||
$urls = ['Treesnap' => "https://treesnap.org/", | ||
'FlorestaDB' => "https://app.florestadb.org/login", | ||
'HealthyWoods' => "https://healthywoodsapp.org/", | ||
'Avid Deer' => "https://aviddeer.com/", | ||
'Eastern Forest Pests' => "https://easternforestpests.com/"]; | ||
|
||
|
||
$treet = Treet::create([ | ||
'app_name' => $request->app_name, | ||
'image_path' => $request->image_path, | ||
'description' => $request->description, | ||
'url' => $urls[$request->app_name] | ||
]); | ||
|
||
return $this->created($treet); | ||
|
||
} | ||
/** | ||
* Show the form for editing the specified resource. | ||
*/ | ||
public function edit(Request $request, Treet $treet) | ||
{ | ||
$urls = ['Treesnap' => "https://treesnap.org/", | ||
'FlorestaDB' => "https://app.florestadb.org/login", | ||
'HealthyWoods' => "https://healthywoodsapp.org/", | ||
'Avid Deer' => "https://aviddeer.com/", | ||
'Eastern Forest Pests' => "https://easternforestpests.com/"]; | ||
|
||
$this->authorize('edit', Treet::class); | ||
|
||
$treet = Treet::find($request->id); | ||
|
||
$treet->update([ | ||
'app_name' => $request->app_name ?: $treet->app_name, | ||
'image_path' => $request->image_path ?: $treet->image_path, | ||
'description' => $request->description ?: $treet->description, | ||
'url' => $urls[$request->app_name] | ||
]); | ||
return $this->success($treet); | ||
|
||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
*/ | ||
public function destroy(Request $request, Treet $treet) | ||
{ | ||
$this->authorize('destroy', Treet::class); | ||
|
||
$treet->find($request->id)->delete(); | ||
return $this->success($treet); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Treet; | ||
use App\User; | ||
use Illuminate\Auth\Access\Response; | ||
|
||
class TreetPolicy | ||
{ | ||
/** | ||
* Determine whether the user can view any models. | ||
*/ | ||
public function viewAny(User $user): bool | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
*/ | ||
public function view(User $user, Treet $treet): bool | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
*/ | ||
public function create(User $user): bool | ||
{ | ||
return $user->isAdmin(); | ||
|
||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
*/ | ||
public function edit(User $user): bool | ||
{ | ||
return $user->isAdmin(); | ||
|
||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
*/ | ||
public function destroy(User $user): bool | ||
{ | ||
return $user->isAdmin(); | ||
|
||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model. | ||
*/ | ||
public function restore(User $user, Treet $treet): bool | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model. | ||
*/ | ||
public function forceDelete(User $user, Treet $treet): bool | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Treet extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'app_name', | ||
'image_path', | ||
'description', | ||
'url' | ||
]; | ||
|
||
protected $casts = [ | ||
'created_at' => 'datetime', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
database/migrations/2024_05_14_164032_create_treets_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. /Users/chancestribling/Sites/Treesnap-website/database/migrations/2024_05_14_164032_create_treets_table.php | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('treets', function (Blueprint $table) { | ||
$table->id(); | ||
$table->text('app_name'); | ||
$table->text('image_path'); | ||
$table->text('url'); | ||
$table->text('description'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('treets'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
use App\Treet; | ||
|
||
|
||
class TreetSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$treets_count = 10; | ||
|
||
factory(Treet::class, $treets_count)->create(); | ||
|
||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, {Component} from 'react' | ||
|
||
export default class RecentUpdates extends Component { | ||
render() { | ||
return ( | ||
<div className="recent-updates"> | ||
<div className="container"> | ||
<h2 className="title is-3 text-white has-text-centered">Recent Updates</h2> | ||
<div className="update-marquee"> | ||
<div className="update-card"> | ||
<h1>The Hemlock survey has been updated to support the Lingering Hemlock Protocol</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
Oops, something went wrong.